Mule 3.7. Add custom SOAP header to web-service-consumer

我怕爱的太早我们不能终老 提交于 2019-12-14 03:58:15

问题


I am trying to customize the soap header in Mule 3.7. By default using the web-service-consumer I get the following:

<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>

However, I would like to change the SOAP header to be:

<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>

Where in Mule do I need to add the below?

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

Does the above need to be added in the ws:consumer-config below?

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


回答1:


I have fixed by adding a message-property-transformer just before the call to the ws-consumer:

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


来源:https://stackoverflow.com/questions/38707554/mule-3-7-add-custom-soap-header-to-web-service-consumer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!