骡子3.7。将自定义SOAP标头添加到web-service-consumer

时间:2016-08-01 20:28:51

标签: web-services soap header mule

我正在尝试在Mule 3.7中自定义soap标头。默认情况下,使用web-service-consumer,我得到以下内容:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <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:mustUnderstand="1">
        <wsse:UsernameToken wsu:Id="UsernameToken-6CF0E33EE8AA1E3DB414700278333141">
            <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"/>
        </wsse:UsernameToken>
    </wsse:Security>
</SOAP-ENV:Header>

但是,我想将SOAP标头更改为:

<soap:Header>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <UsernameToken>
        <Username>TEST</Username>
    </UsernameToken>
</Security>

我需要在Mule中添加以下内容吗?

<set-property propertyName="soap.Authorization"
value="<auth>Bearer MWYxMDk4ZDktNzkyOC00Z</auth>"/>

以上是否需要在ws:consumer-config下添加?

<ws:consumer-config name="WSConsumerConfig" wsdlLocation="${wsdl.location}"
service="aService" port="aServiceHttpPort" serviceAddress="${service.url}"
connectorConfig="HTTPRequestConfig" doc:name="Web Service Consumer">

1 个答案:

答案 0 :(得分:2)

我已经通过在调用ws-consumer之前添加了一个message-property-transformer来修复:

<message-properties-transformer doc:name="Message Properties">
                <add-message-property key="soap.header" value="${web.service.username.token}"/>
            </message-properties-transformer>