我试图在不使用apache cxf作为端点的情况下调用具有来自apache camel的ws安全性的wsdl服务。
这是怎么做到的?
提前致谢。
答案 0 :(得分:1)
来自apache camel的没有使用apache cxf
Camel是一个集成框架(在端点之间传递消息)。 Camel itelf无法在没有Camel端点的情况下调用任何外部服务(这是了解如何调用特定服务/技术的逻辑)
所以 - 如果你想用安全性调用Web服务,你需要一些框架来签署或验证Soap消息(你真的不想自己这样做)
如何使用Camel和CXF执行此操作:https://pastebin.com/ALcnzfVf(此示例用于公开服务,而不是消耗/调用,但原理相同且配置非常相似)
<camelcxf:cxfEndpoint id="egovAddressEndpoint"
address="/egov/api/external/AddressService"
xmlns:addr="http://address.ws.egov.xxx.com/v1_0/ws"
serviceName="addr:eGovAddressService"
endpointName="addr:AddressServicePortBinding"
serviceClass="com.xxx.egov.ws.address.v1_0.ws.EGovAddressService">
<!-- wsdlURL="classpath:com/xxx/egov/ws/address/v1_0/AddressService.wsdl"-->
<camelcxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
<!-- maybe one of these is enough, I put both directives to be sure.
The intention is not to provide a password callback, but let the CXF
use an underlaying security context to authenticate and authorize users -->
<entry key="ws-security.ut.no-callbacks" value="true"/>
<entry key="ws-security.validate.token" value="false"/>
</camelcxf:properties>
<camelcxf:outInterceptors>
<!--<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>-->
</camelcxf:outInterceptors>
<camelcxf:inInterceptors>
<!--<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>-->
<ref component-id="wsSecInterceptor" />
<ref component-id="authenticationInterceptor"/>
<ref component-id="authorizationInterceptor" />
</camelcxf:inInterceptors>
</camelcxf:cxfEndpoint>
<bean id="wsSecInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<argument>
<map>
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordText"/>
</map>
</argument>
</bean>