Versions Compared

Key

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

...

Example 1: Setting the property symbol

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

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>

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

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:

Code Block
languagehtml/xml
<proxy xmlns="http://ws.apache.org/ns/synapse" name="_TestEnrich" transports="https,http" statistics="disable" trace="enable" startOnLoad="true"> 
   <target> 
      <inSequence> 
         <enrich> 
            <source type="inline" clone="true"> 
               <Cars/> 
            </source> 
            <target type="property" property="Cars"/> 
         </enrich> 
         <log level="custom"> 
            <property name="PekeCarListBeforeEnrich" expression="get-property('Cars')"/> 
         </log> 
         <enrich> 
            <source type="inline" clone="true"> 
               <Car>Lamborghini</Car> 
            </source> 
            <target action="child" xpath="$ctx:Cars"/> 
         </enrich> 
         <log level="custom"> 
            <property name="PekeCarListAfterEnrich" expression="get-property('Cars')"/> 
         </log> 
      </inSequence> 
      <outSequence/> 
   </target> 
   <description></description> 
</proxy>

...

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.
    Image Added
  2. Configure the Enrich Mediator as shown below.

    Image Added
Excerpt
hiddentrue

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

For another example using the Enrich mediator, see Sample 440: Converting JSON to XML Using XSLT.

...