WSO2 ESB : Enrich Mediator

The Enrich mediator of WSO2 ESB can be used to perform transformations within your integration logic. Most transformations which needs an XSLT, can be easily done using this mediator. An article which is written on ESB service chaining can be found here and it uses the Enrich mediator to perform transformations. In the example given in the article, it is used to copy values coming in a SOAP message to some other SOAP message. But there can be situations where you want to copy a complete XML element from one message to another. In such situations, Enrich mediator can be used as shown below within your synapse configuration.

        <source xmlns:xs="" clone="true" xpath="//xs:Patients"/>
        <target type="property" property="PATIENTS"/>
        <source type="inline" clone="true">
            <p:aggregate xmlns:p="">
        <target type="body"/>
        <source type="property" clone="true" property="PATIENTS"/>
        <target xmlns:p="" xpath="//p:aggregate/p:Patients"/>

In the above configuration, if you are in the out sequence of your proxy service, first enrich block copies the “xs:Patients” element from the response from your first invocation into a property. Then the second enrich block creates the request to be sent to your second service. In the third enrich block, the PATIENTS property is inserted in the place of “//p:aggregate/p:Patients” element of the second request we just created. This will make sure that the entire “Patients” element will be copied into the second request as it is.