This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

All docs This doc
Skip to end of metadata
Go to start of metadata

The Enrich Mediator can process a message based on a given source configuration and then perform the specified action on the message by using the target configuration. It basically gets an OMElement using the configuration specified in the source and then modifies the message by putting it on the current message using the configuration in the target.


    <source [clone=true|false] [type=custom|envelope|body|property|inline] xpath="" property="" />
    <target [action=replace|child|sibiling] [type=custom|envelope|body|property|inline] xpath="" property="" />

UI Configuration

The main properties of the Enrich Mediator available are:

Source Configuration

The following properties are available:

  • Clone- By setting the clone configuration, the message can be cloned or used as a reference during enriching. The default value is true.
    • True
    • False
  • Type- The type that the mediator uses from the original message to enrich the modified message that passes through the mediator.
    • Custom - Custom XPath value.
    • Envelope - Envelope of the original message used for enriching.
    • Body - Body of the original message used for enriching.
    • Property - Specifies a property.
    • Inline - Specifies an inline XML value.
  • XPath Expression


You can click the Namespaces link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor," where you can provide any number of namespace prefixes and URL that you have used in the XPath expression. 

Target Configuration

The following properties are available:

  • Action- By specifying the action type, the relevant action can be applied to outgoing messages.
    • Replace - Replace is the default value of Action. It will be used if a specific value for Action is not given. This replaces the XML message based on the target type specified on the target configuration. 
    • Child - Adding as a child of the specified target type.
    • Sibling - Adding as a sibling of the specified target type.

Type and XPath Expression - Refer to "Source Configuration" above.


You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.

Example 1: Setting the property symbol

In this example, we are setting the property symbol. Later, you can log it using the Log Mediator.

<enrich xmlns="">
           <source clone="false" type="envelope" xpath="" property="" />
           <target action="replace" type="body" xpath="" property="" />

Example 2: Adding a child object to a property

In this example, we add a child property named Lamborghini to a property named Cars. The configuration for this is as follows:

<proxy xmlns="" name="_TestEnrich" transports="https,http" statistics="disable" trace="enable" startOnLoad="true"> 
            <source type="inline" clone="true"> 
            <target type="property" property="Cars"/> 
         <log level="custom"> 
            <property name="PekeCarListBeforeEnrich" expression="get-property('Cars')"/> 
            <source type="inline" clone="true"> 
            <target action="child" xpath="$ctx:Cars"/> 
         <log level="custom"> 
            <property name="PekeCarListAfterEnrich" expression="get-property('Cars')"/> 

The child property can also be added using the design view as shown below.

  1. Add the Enrich mediator as a child to the required sequence as shown below.

  2. Configure the Enrich Mediator as shown below.

Example 3 - Adding a SOAPEnvelope type object as a property to a message

In this example, we add the SOAP envelope in a SOAP request as a property to a message. The Enrich mediator is useful in this scenario since adding the property directly using the Property mediator results in the SOAPEnvelope object being created as an OM type object. The OM type object created cannot be converted back to a SOAPEnvelope object.

<source type="envelope" clone="true"/>
<target type="property" property="ExtractedEnvelope"/>


Example 4 - Preserving the original payload


In this example, you copy the original payload to a property using the Enrich mediator.


      <source clone="false" type="body"/>
      <target action="replace" type="property" property="ORGINAL_PAYLOAD"/>


Then whenever you need the original payload, you replace the message body with this property value using the Enrich mediator as follows:


      <source clone="false" type="property" property="ORIGINAL_PAYLOAD"/>
      <target action="replace" type="body"/>


For other example using the Enrich mediator, see 
Sample 15: Using the Enrich Mediator for Message Copying and Content Enrichment and Sample 440: Converting JSON to XML Using XSLT.

  • No labels