This blog post will explain a scenario of using script mediator with a Json payload.
Configure back-end
==============
1. Deploy this webapp in an appserver.
https://svn.wso2.org/repos/wso2/trunk/commons/qa/qa-artifacts/esb/esb481/JSONscenarios/withScriptMediator/pizzashop-rs_1.0.zip
Configure ESB
=============
2. Provide the following api synapse configuration.
<api name="pizzashop" context="/pizzashop"> <resource methods="GET" uri-template="/api/menu/pizza*"> <inSequence> <send> <endpoint> <http method="get" uri-template="http://localhost:9765/pizzashop-rs_1.0/services/menu/pizza/all"/> </endpoint> </send> </inSequence> <outSequence> <log level="full"/> <script language="js">var payload = mc.getPayloadJSON();mc.setPayloadJSON(payload); </script> <send/> </outSequence> </resource> </api>
Invoking the service
==============
3. Invoke the service
curl -v "http://localhost:8280/pizzashop/api/menu/pizza/all"
You will get all the available pizza list.
No comments:
Post a Comment