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>
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>
Don't find fault, find a remedy. See the link below for more info.
ReplyDelete#fault
www.ufgop.org