Assume that you will get a json request to ESB as following
{"name": "Jack","location": "Australia"}
Then add a property mediator to proxy
<property name="messageType" value="text/xml" scope="axis2"/>
Get the following payload in wso2carbon.log after enable the wire log
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<jsonObject>
<name>Jack</name>
<location>Australia</location>
</jsonObject>
</soapenv:Body>
</soapenv:Envelope>
To remove jsonObject from the payload add an enrich mediator
<enrich>
<source clone="true" xpath="$body//jsonObject//name"/>
<target type="body"/>
</enrich>
Then add a log mediator after enrich mediator and see the carbon.log
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<name>Jack</name>
<location>Australia</location>
</soapenv:Body>
</soapenv:Envelope>
You can use following proxy and check the full scenario explained above.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="abcd"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="messageType" value="text/xml" scope="axis2"/>
<enrich>
<source clone="true" xpath="$body//jsonObject//name"/>
<target type="body"/>
</enrich>
<log level="full"/>
<send>
<endpoint>
<address uri="http://www.google.com"/>
</endpoint>
</send>
</inSequence>
</target>
<description/>
</proxy>
Thanks
No comments:
Post a Comment