如何将安全标头参数添加到SOAP请求

时间:2016-02-02 10:29:57

标签: java web-services soap soap-client

我必须向Soap请求添加安全标头,如下所示,

<soapenv:Header>
  <wsse:Security soapenv:mustUnderstand="1" 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">
    <wsse:UsernameToken wsu:Id="UsernameToken-2349028390dnjnsja
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">sdfasfdweww</wsse:Nonce>
        <wsu:Created>2016-02-02T10:21:26.247Z</wsu:Created>
    </wsse:UsernameToken>
  </wsse:Security>
</soapenv:Header>

我正在以下方式进行,但是获取404 - Address Not Found错误并且标头未添加到SOAP请求中。

        BindingProvider provider = (BindingProvider) ars1;
        provider.getRequestContext().put(Message.ENDPOINT_ADDRESS, getEndPointURL(proxyType)) ;

        AuthorizationPolicy authzPolicy = new AuthorizationPolicy();
        authzPolicy.setUserName("username");
        authzPolicy.setPassword("password");
        provider.getRequestContext().put(AuthorizationPolicy.class.getName(), authzPolicy);

它出了什么问题?

0 个答案:

没有答案