如何将安全令牌添加到Web服务客户端调用

时间:2012-11-17 04:12:33

标签: java web-services apache soap

我正在使用Java客户端为使用Apache CXF运行的Web服务创建Soap请求。我已将UserNameToken添加到客户端消息,但Apache CXF无法在AbstractUsernameTokenAuthenticatingInterceptor类中处理它,因为缺少SecurityToken。

如何将SecurityToken添加到SoapHeader?

我正在使用Java来创建SoapMessage。进入webservice的SoapHeader看起来像:

<S:Header><wsse:Security xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"    

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-.0.xsd" 
SOAP-ENV:mustUnderstand="1">
<wsse:UsernameToken wsu:Id="UsernameToken-2" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">user</wsse:Username>
<wsse:Password xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
</wsse:UsernameToken></wsse:Security></S:Header>

0 个答案:

没有答案