java - 如何使用基本身份验证配置 Camel CXF

标签 java cxf apache-camel

我是 Apache Camel 和 CXF 的新手,

我正在尝试创建一个路由来查询需要基本身份验证的远程 WS,并指定 Soap Action header 。

我能够使用 camel HTTP 组件实现相同的效果,但我需要使用 camel CXF 实现相同的效果 在 Java DSL 中

谁能指导我们解决同样的问题

最佳答案

如果你想使用 camel-cxf 组件来设置 Basic 认证,你需要像这样在 CxfEndpoint 上做一些配置。

CxfEndpoint cxfEndpoint = camelContext.getEndpoint(“cxf:xxx”); 
// set the authentication information 
Map<String, Object> properties = new HashMap<String, Object>(); 

org.apache.cxf.configuration.security.AuthorizationPolicy authPolicy = new AuthorizationPolicy(); 
authPolicy.setUserName(username); 
authPolicy.setPassword(password); 
properties.put(AuthorizationPolicy.class.getName(), authPolicy); 

cxfEndpoint.setProperties(properties);     

from(“xxx”).to(cxfEndpoint); 

关于java - 如何使用基本身份验证配置 Camel CXF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20948182/

相关文章:

JAVA BigInteger类错误: BigInteger: modulus not positive

java - Camel RabbitMQ 消费者 : what's the interaction between concurrentConsumers and threadPoolSize options?

java - 将文本添加到另一个类的标签 - 简单的逻辑问题

java - 如何在 JPA 中使用 TypedQuery 更改顺序

rest - 是否可以使用 MTOM 响应 CXF RESTful Web 服务

java - 如何告诉 Apache CXF 在 Spring 配置中使用 java.util.Date

java - RabbitMQ 和 Camel : route interrupted due to "Message dropped on recovery"

java - 使用 Apache Camel 删除文件

java - 如何确保所有字段都加载到 selenium 中的页面上,以便没有一个字段过时?

尝试排除逗号时,Java RegEx 模式无效