Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel3
minLevel3
locationtop
styleborder:1locationtop
typeflat
separatorpipe

...

Syntax

...

  • Clone- By setting the clone configuration, the message can be cloned or used as a reference during enriching. The default value is falsetrue.
    • 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

...

Code Block
XML
XML
<enrich xmlns="http://ws.apache.org/ns/synapse">
           <source clone="false" type="envelope" xpath="" property="" />
           <target action="replace" type="body" xpath="" property="" />
 </enrich>

...


Example 2: Adding a child object to a property

...

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



  2. Configure the Enrich Mediator as shown below.


 

Excerpt
hiddentrue

Example 2 is written with reference to /wiki/spaces/FAQ/pages/37781537. 

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. 

Code Block
languagexml
<enrich> 
<source type="envelope" clone="true"/>
<target type="property" property="ExtractedEnvelope"/>
</enrich> 
 
Excerpt
hiddentrue

Added this content for the FAQ When ExtractedEnvelope is a SOAPEnvelope with OM type, why do we get "EnrichMediator SOAPEnvelope is expected" for SOAP requests?

For another

 

Example 4 - Preserving the original payload

 

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

 

Code Block
languagexml
<enrich>
      <source clone="false" type="body"/>
      <target action="replace" type="property" property="ORGINAL_PAYLOAD"/>
   </enrich>

 

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

 

Code Block
languagexml
<enrich>
      <source clone="false" type="property" property="ORIGINAL_PAYLOAD"/>
      <target action="replace" type="body"/>
   </enrich>

 


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

Excerpt
hiddentrue

Description of the Enrich Mediator in WSO2 ESB.