Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Custom SOAP headers can be added You can add custom SOAP headers using the following methods:

Table of Contents
maxLevel3

Using the Payload Factory mediator

You can add custom SOAP headers to a request by using the PayloadFactory Mediator in the proxy service as shown in the example below.

...

Excerpt
hiddentrue

This content was added for the FAQ How to add custom SOAP headers to a request?.

Using the Script mediator

You can add custom SOAP headers to a request by using the addHeader(mustUnderstand, content) of the Script Mediator in the proxy service as shown in the example below.

Code Block
languagexml
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="CustomSOAPHeaderProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <log level="full">
            <property name="Message" value="IncomingRequest"/>
         </log>
         <script language="js">mc.addHeader(false, &lt;ns:sampleCustomHeader xmlns:ns="gsb:http://wso2.org/sample"&gt;&lt;ns:customInfo&gt;CustomHeader&lt;/ns:customInfo&gt;&lt;/ns:sampleCustomHeader&gt;);</script>
         <log level="full">
            <property name="Message" value="UpdatedMessage"/>
         </log>
         <drop/>
      </inSequence>
   </target>
   <description/>
</proxy>