我正在研究基于 CXF 的服务和客户端。并使用 wsdl 中定义的策略文件在服务器端实现用户名密码安全。这是配置:
<wsp:Policy wsu:Id="policy.Security" xmlns:wsp="http://www.w3.org/ns/ws-policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SupportingTokens>
<wsp:Policy>
<sp:UsernameToken
sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"
wsp:Optional="false" wsp:Ignorable="false">
<wsp:Policy>
<sp:WssUsernameToken10 />
<sp13:Created />
<sp13:Nonce />
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SupportingTokens>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
客户端配置:
<jaxws:client
xmlns:tns="http://ws.soa.com/service/offer/XYZ/"
name="XYZPort" address="${xyz.endPoint}"
serviceClass="com.soa.ws.service.offer.XYZ.XYZPortType"
wsdlLocation="${xyz.wsdlLocation}" serviceName="tns:xyzService" >
<jaxws:properties>
<entry key="ws-security.username" value="${xyz.auth.username}" />
<entry key="ws-security.callback-handler" value-ref="xyzPasswordCallback" />
</jaxws:properties>
<jaxws:inInterceptors>
<ref bean="logInBound" />
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref bean="logOutBound" />
</jaxws:outInterceptors>
</jaxws:client>
在尝试访问服务时收到以下错误:
引起:javax.xml.ws.soap.SOAPFaultException:无法满足这些策略替代方案:{ http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702 }UsernameToken:用户名令牌创建策略未在 org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157) 强制执行
任何人都可以就如何解决这个问题提供指导吗?