如何配置骆驼CXF与基本身份验证 [英] How to configure Camel CXF with Basic authentication
本文介绍了如何配置骆驼CXF与基本身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来的Apache骆驼和CXF,
I'm new to Apache Camel and CXF,
我试图创建一个路由查询需要基本身份验证,并指定SOAP动作头远程WS。
I'm trying to create a route for querying a remote WS which requires Basic Authentication and to specify the Soap Action header.
我能够用骆驼HTTP组件来实现相同的,但我需要用骆驼CXF相同
在Java DSL
I was able to achieve the same using camel HTTP component but i needed the same with camel CXF in java DSL
任何人都可以指导我们固定在同一
Can anyone guide us in fixing the same
推荐答案
如果你想使用骆驼CXF组件设置基本身份验证,你需要做的CxfEndpoint一些配置就是这样的。
If you want to use camel-cxf component to setup the Basic authentication, you need do some configuration on the CxfEndpoint just like this.
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);
这篇关于如何配置骆驼CXF与基本身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文