How to Add new Namespace to SOAP Envelope


There are some points you may face instead of keeping the body content’s namespace in the SOAP envelope, in such scenarios you can use Enrich Mediator to get this done.

Add the following enrich mediators three times and add new namespace to envelope where ever you want. And then use the new namespace inside a payload factory mediator.

   <enrich>
      <source type="body" />
      <target type="property" property="ORG_BODY" />
   </enrich>
   <enrich>
      <source type="inline">
         <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:newns="http://abc.com">
            <soapenv:Body />
         </soapenv:Envelope>
      </source>
      <target type="envelope" />
   </enrich>
   <enrich>
      <source type="property" property="ORG_BODY" />
      <target type="body" />
   </enrich>
   <payloadfactory>
      <!--we have to define the new namespace here too but it doesn't appear in the new body since it's already defined in the envelope tag -->
      <newns:bodycontent xmlsns:newns="http://abc.com">.....</newns:bodycontent>
   </payloadfactory>