Wednesday, December 10, 2014

Remove the payload and send POST request to backend via wso2 esb

There are situations where back-end does not need a payload for POST request. However in wso2 ESB has the payload that mediate before the back-end call. In order to drop the message payload you need to perform two tasks in the wso2 ESB.



Example is given below that demonstrate the use case. 

<api xmlns="http://ws.apache.org/ns/synapse" name="strip" context="/strip">
<resource methods="POST GET">
<inSequence>
<header name="Authorization" scope="transport" value="Bearer XXXXXXXXXXXXXXXXXXXXX"></header>
<property name="uri.var.chargeId" expression="json-eval($.chargeId)" scope="default" type="STRING"></property>
<payloadFactory media-type="json">
<format></format>
<args></args>
</payloadFactory>
<property name="ContentType" value="application/x-www-form-urlencoded" scope="axis2"></property>
<property name="messageType" value="application/x-www-form-urlencoded" scope="axis2"></property>
<property name="FORCE_POST_PUT_NOBODY" value="true" scope="axis2" type="BOOLEAN"></property>
<call>
<endpoint>
<address uri="https://api.stripe.com/v1/charges/{uri.var.chargeId}/refunds"></address>
</endpoint>
</call>
<respond></respond>
</inSequence>
</resource>
</api>
view raw gistfile1.txt hosted with ❤ by GitHub

No comments:

Post a Comment