WSO2 ESB Removing full soap header using enrich mediator.

WSO2 ESB supports many mediators, and we can use them to achieve most of our use cases.

The following message template illustrates the structure of a SOAP Envelope:


<soap:Envelope   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header> <!-- optional -->
    <!-- header blocks go here... -->
  </soap:Header>
  <soap:Body>
    <!-- payload or Fault element goes here... -->
  </soap:Body>
</soap:Envelope>



Even though soap header is optional, you might receive the soap envelop with soap headers. And you might need to remove the soap header element including <soap:Header></soap:Header> element.

You can achieve this by using enrich mediator and payload factory mediator.
We first extract the body from the soap envelop and assign it to a property using enrich mediator. Then we create an empty soap envelop using payload factory. At last enrich mediator is again used to put the soap body to soap envelop from the property.

          <enrich>
            <source type="body" clone="true"/>
            <target type="property" property="ORIGINAL_BODY"/>
         </enrich>

         <payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                  <soapenv:Body/>
               </soapenv:Envelope>
            </format>
            <args/>
         </payloadFactory>

         <enrich>
            <source type="property" clone="true" property="ORIGINAL_BODY"/>
            <target type="body"/>
         </enrich>

Comments

  1. Don't find fault, find a remedy. See the link below for more info.


    #fault
    www.ufgop.org

    ReplyDelete

Post a Comment

Popular posts from this blog

WSO2 ESB append full body to a POST parameter

WSO2 ESB supporting VFS transport with FTPS Protocol with File Encryption