...
Code Block |
---|
|
<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> |
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 |
---|
|
<enrich>
<source type="envelope" clone="true"/>
<target type="property" property="ExtractedEnvelope"/>
</enrich> |
Example 4 - Preserving the original payload
In this example, you copy the original payload to a property using the Enrich mediator.
Code Block |
---|
|
<enrich>
<source clone="false" type="body"/>
<target action="replace" type="property" property="ORIGINAL_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 |
---|
|
<enrich>
<source clone="false" type="property" property="ORIGINAL_PAYLOAD"/>
<target action="replace" type="body"/>
</enrich> |
For other examples 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.