如何在SOAP标头请求中发送普通用户名和密码?

时间:2017-05-18 06:54:33

标签: web-services soap spring-ws

如何在SOAP标头请求中发送普通用户名和密码?

目前的配置如下:

<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
        <property name="marshaller" ref="jaxb2Marshaller"></property>
        <property name="unmarshaller" ref="jaxb2Marshaller"></property>
        <property name="defaultUri"><value>${ws.url}</value></property>
        <property name="interceptors">  
            <list>  
                <ref local="wsClientSecurityInterceptor"/>  
            </list>  
        </property>
    </bean>

    ...
        <bean id="wsClientSecurityInterceptor"  
        class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">  
        <property name="securementActions" value="UsernameToken" />  
        <property name="securementUsername"><value>${exacttarget.ws.username}</value></property>  
        <property name="securementPassword"><value>${exacttarget.ws.password}</value></property>  
    </bean>

但生成的密码如下:

<SOAP-ENV:Header>
        <wsse:Security
            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" SOAP-ENV:mustUnderstand="1">
            <wsse:UsernameToken wsu:Id="UsernameToken-0D2A3753C819EC67F714950869115581">
                <wsse:Username>testuser</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">1234435erwerwerwerwe=</wsse:Password>
                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">YJTk+IJ8jIKJSFrDT7Y0mw==</wsse:Nonce>
                <wsu:Created>2017-05-18T05:55:11.557Z</wsu:Created>
            </wsse:UsernameToken>
        </wsse:Security>
    </SOAP-ENV:Header>

我应该在配置中更改哪些密码才会显示在PLAIN中?

1 个答案:

答案 0 :(得分:0)

添加一个额外的属性&#34; securementPasswordType&#34;帮助我实现了它。

<bean id="wsClientSecurityInterceptor"  
    class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">  
    <property name="securementActions" value="UsernameToken" />  
    <property name="securementUsername"><value>AAAA</value></property>  
    <property name="securementPassword"><value>BBBB</value></property>
    <property name="securementPasswordType" value="PasswordText" />
</bean>