Default soap envelope namespace in WSO2 is xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/”, as in the payload below:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
..........
</soap:Body>
</soap:Envelope>

Sometimes is useful to be able to change the payload envelope namespace or namespace prefix, for example, when you want to use soap 1.2 that requires it to be xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/”

In order to change the namespace in a WSO2 ESB sequence you should use an enrich mediator.
In fact you’ll use 3 enrich mediators for the following steps:

1. Save the original body

<enrich>
<source type="body"/>
<target type="property" property="INPUT_MESSAGE"/>
</enrich>

2. Change soap envelope to a new one with the correct namespace

<enrich>
<source type="inline">
<myns:Envelope xmlns:myns="http://schemas.xmlsoap.org/soap/envelope/">
<myns:Body/>
</myns:Envelope>
</source>
<target type="envelope"/>
</enrich>

3. Restore the original body to the new payload envelope

<enrich>
<source type="property" property="INPUT_MESSAGE"/>
<target type="body"/>
</enrich>

So you’re sequence will look like these:

<sequence name="seTestChangeNamespace" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
(...)
<enrich>
<source type="body"/>
<target type="property" property="INPUT_MESSAGE"/>
</enrich>
<enrich>
<source type="inline">
<myns:Envelope xmlns:myns="http://schemas.xmlsoap.org/soap/envelope/">
<myns:Body/>
</myns:Envelope>
</source>
<target type="envelope"/>
</enrich>
<enrich>
<source type="property" property="INPUT_MESSAGE"/>
<target type="body"/>
</enrich>
(...)
</sequence>

Hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>