Using Clone and Aggregate Mediators — WSO2 ESB / WSO2 MI

<resource methods=”GET” uri-template=”/getDetails/{customer_Id}”>
<log level="custom">
<property name="LOG" value="Calling GetCustomerDetails API *********"/>
</log>
<clone id="RESPONSE">
<target>
<sequence>
<call>
<endpoint>
<http method="get" uri-template="http://run.mocky.io/v3/51971833-3287-4c25-8e69-79f5ceecb454">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
</sequence>
</target>
<target>
<sequence>
<call>
<endpoint>
<http method="get" uri-template="http://run.mocky.io/v3/c3d12cfd-468d-4ab9-9845-2a12c6bdb112">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
</sequence>
</target>
</clone>
<log level="custom">
<property name="LOG" value="Calling GetCustomerDetails API Ended*********"/>
</log>
<property name="info" scope="default">
<ns:Info xmlns:ns="http://wso2.com"/>
</property>
<aggregate id="RESPONSE">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete aggregateElementType="root" enclosingElementProperty="info" expression="s11:Body/child::* | s12:Body/child::*" xmlns:m0="http://services.samples" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s12="http://www.w3.org/2003/05/soap-envelope">
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<respond/>
</onComplete>
</aggregate>
<?xml version="1.0" encoding="UTF-8"?>
<api context="/GetCustomerDetails" name="GetCustomerDetails" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/getDetails/{customer_Id}">
<inSequence>
<log level="custom">
<property name="LOG" value="Calling GetCustomerDetails API *********"/>
</log>
<clone id="RESPONSE">
<target>
<sequence>
<call>
<endpoint>
<http method="get" uri-template="http://run.mocky.io/v3/51971833-3287-4c25-8e69-79f5ceecb454">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
</sequence>
</target>
<target>
<sequence>
<call>
<endpoint>
<http method="get" uri-template="http://run.mocky.io/v3/c3d12cfd-468d-4ab9-9845-2a12c6bdb112">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
</sequence>
</target>
</clone>
<log level="custom">
<property name="LOG" value="Calling GetCustomerDetails API Ended*********"/>
</log>
<property name="info" scope="default">
<ns:Info xmlns:ns="http://wso2.com"/>
</property>
<aggregate id="RESPONSE">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete aggregateElementType="root" enclosingElementProperty="info" expression="s11:Body/child::* | s12:Body/child::*" xmlns:m0="http://services.samples" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s12="http://www.w3.org/2003/05/soap-envelope">
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<respond/>
</onComplete>
</aggregate>
</inSequence>
<outSequence>
<log level="custom">
<property name="LOG" value="Outsequence*********"/>
</log>
</outSequence>
<faultSequence/>
</resource>
</api>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store