In this scenario I need to send a post request to two different REST services, I am using REST API configuration of WSO2 ESB First I need to post a request to first service and based on successful posting then need to post this same original request to another service and also But I need to obtain the response from first service and send it to client.However I do not need to obtain the response from second service.
I have illustrate this scenario in the simple flow diagram.
Relevant Synapse configuration.
I have illustrate this scenario in the simple flow diagram.
Relevant Synapse configuration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<api xmlns="http://ws.apache.org/ns/synapse" name="TestApi" context="/TestContext"> | |
<resource methods="POST GET"> | |
<inSequence> | |
<log level="custom"> | |
<property name="Message Flow" value="Roovershof Plant Search API - IN"></property> | |
<property name="HTTP_METHOD IS###########" expression="$axis2:HTTP_METHOD"></property> | |
<property name="ip address" expression="get-property('axis2','REMOTE_ADDR')"></property> | |
<property name="Authorization" expression="get-property('transport','Authorization')"></property> | |
</log> | |
<property name="TIME_IN" expression="get-property('SYSTEM_TIME')" scope="default" type="LONG"></property> | |
<enrich> | |
<source type="body" clone="true"></source> | |
<target type="property" property="INIT_MSG_PAYLOAD"></target> | |
</enrich> | |
<call> | |
<endpoint> | |
<address uri="service1"></address> | |
</endpoint> | |
</call> | |
<filter source="get-property('axis2', 'HTTP_SC')" regex="201"> | |
<then> | |
<clone continueParent="true"> | |
<target> | |
<sequence> | |
<respond></respond> | |
</sequence> | |
</target> | |
<target> | |
<sequence> | |
<enrich> | |
<source type="property" clone="true" property="INIT_MSG_PAYLOAD"></source> | |
<target type="body"></target> | |
</enrich> | |
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"></property> | |
<property name="messageType" value="application/json" scope="axis2"></property> | |
<property name="HTTP_METHOD" value="POST" scope="axis2"></property> | |
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" type="STRING"></property> | |
<property name="OUT_ONLY" value="true" scope="default" type="STRING"></property> | |
<send> | |
<endpoint> | |
<address uri="servicr2"></address> | |
</endpoint> | |
</send> | |
</sequence> | |
</target> | |
</clone> | |
</then> | |
<else> | |
<respond/> | |
</else> | |
</filter> | |
</inSequence> | |
</resource> | |
</api> |