Spring 如何更改Soap头消息

Spring 如何更改Soap头消息,spring,soap,soapui,soap-client,spring-ws,Spring,Soap,Soapui,Soap Client,Spring Ws,我有soap请求要发送到服务。在发送之前,我想编辑Soap头 <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"> 通过将mustUnderstand值传递为0,我检查了Soap UI,结果成功了。现在我想从我的客户那里寄同样的东西 我试图在应用程序ConextB

我有soap请求要发送到服务。在发送之前,我想编辑Soap头

<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
通过将
mustUnderstand
值传递为0,我检查了Soap UI,结果成功了。现在我想从我的客户那里寄同样的东西

我试图在应用程序ConextBean定义xml文件中添加参数,但并没有按照下面的步骤进行

<property name="securementmustUnderstand"><value>false</value></property>
下面是生成的soap消息

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-3">
                <wsse:Username>test</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <ns3:GetRegInfo xmlns:ns3="http://www.test.com/regester" xmlns:ns2="http://www.test.com/regester2" xmlns:ns4="http://com.test.com.services.register">
            <ns3:personId>10</ns3:personId>
        </ns3:GetRegInfo>
    </soapenv:Body>
</soapenv:Envelope>

测试
测试
10

您为哪个bean添加了该属性?请把整个
元素放在你的问题中,而不是一个片段。你真的在用这个模板来构造soap消息吗?如何创建要发送的消息…我是此Soap Web服务的新手。我不确定soap消息是如何构造的。我正在使用下面的代码发送和接收请求和响应regWebServiceTemplate.marshalSendAndReceive(请求),其中请求是schema类的对象,该类具有我要发送到web服务的字段的getter和setter方法。启用日志记录并弄清楚发送的内容。将
org.springframework.ws.client.MessageTracing
设置为
trace
时,您将得到实际发送的消息。检查正在设置的值。请不要将其添加为注释,将其添加到您的问题中。。。
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <bean id="reg" class="com.service.RegConsServiceImpl">
        <property name="regWebServiceTemplate" ref="regWebServiceTemplate"/>
    </bean>
    <bean id="regWebServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
        <constructor-arg ref="messageFactory"/>
        <property name="marshaller" ref="marshaller"/>
        <property name="unmarshaller" ref="unmarshaller"/>
        <property name="interceptors">          
            <list>
                <ref bean="wsRegClientSecurityInterceptor"/>
            </list>
        </property> 
    </bean>

    <bean id="wsRegClientSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
        <property name="securementmustUnderstand">
            <value>false</value>
        </property>
        <property name="securementActions" value="UsernameToken" />
        <property name="securementPasswordType" value="PasswordText"/>
        <property name="securementPassword">
            <value>${registration.ws.password}</value>
        </property>
        <property name="securementUsername">
            <value>${registration.ws.username}</value>
        </property>
    </bean>
</beans>
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-3">
                <wsse:Username>test</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <ns3:GetRegInfo xmlns:ns3="http://www.test.com/regester" xmlns:ns2="http://www.test.com/regester2" xmlns:ns4="http://com.test.com.services.register">
            <ns3:personId>10</ns3:personId>
        </ns3:GetRegInfo>
    </soapenv:Body>
</soapenv:Envelope>