You would like to set the SOAP header in a Web Service Consumer connector in Mule 4 APIs.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > <soapenv:Header> <tsh:AuthenticationHeader xmlns:tsh="http://mulesoft.org/tshirt-service"> <apiKey>MaxTheMule</apiKey> </tsh:AuthenticationHeader> </soapenv:Header> <soapenv:Body> <tsh:TrackOrder> <email>test@mulesoft.com</email> <orderId>123456</orderId> </tsh:TrackOrder> </soapenv:Body> </soapenv:Envelope>
%dw 2.0
output application/xml
ns ns0 http://mulesoft.org/tshirt-service
---
headers : {
ns0#AuthenticationHeader: {
apiKey: "MaxTheMule"
}
}
%dw 2.0
output application/xml
ns ns0 http://mulesoft.org/tshirt-service
ns ns01 http://schemas.xmlsoap.org/soap/envelope/
---
{
ns0#TrackOrder: {
email: "test@mulesoft.com",
orderId: "123456"
}
}
<soapenv:Header>
<wsse:Security wsu:ID="UsernameToken-XXX" 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>
<wsse:Username Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">user@company.com</wsse:Username>
<wsse:Password>password123</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
In the Transform message you can do the following:
%dw 2.0
output application/xml
ns soapenv http://schemas.xmlsoap.org/soap/envelope/
ns wsse http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
ns wsu http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
---
headers : {
wsse#Security @(wsu#ID:"UsernameToken-XXX"): {
wsse#UsernameToken: {
wsse#Username @(Type:"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"): "user@company.com",
wsse#Password: "password123"
}
}
}
001114743

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.