我是 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/