How to configure Camel CXF with Basic authentication(如何使用基本身份验证配置 Camel CXF)
问题描述
我是 Apache Camel 和 CXF 的新手,
I'm new to Apache Camel and CXF,
我正在尝试创建一个路由来查询需要基本身份验证的远程 WS 并指定 Soap Action 标头.
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
推荐答案
如果你想使用camel-cxf组件设置Basic认证,你需要像这样在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);
这篇关于如何使用基本身份验证配置 Camel CXF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用基本身份验证配置 Camel CXF


基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01