Most of the current docs are with reference to SOAP-to-JSON, I was hoping whether there are any reference material or tutorials when using WSO2 ESB to transform JSON response object to SOAP service. Thanks in advance.
Sample service: http://api.statsfc.com/premier-league/table.json?key=free
You can achieve this with a configuration similar to the following; (We must set the "messageType" property to "text/xml" to engage the SOAP message builder when responding back to the client.)
<proxy xmlns="http://ws.apache.org/ns/synapse" name="JSONToSOAPService" transports="https,http">
<target>
<outSequence>
<log level="full"/>
<property name="messageType" value="text/xml" scope="axis2"/>
<send/>
</outSequence>
<endpoint>
<address uri="http://api.statsfc.com/premier-league/table.json?key=free"/>
</endpoint>
</target>
<description></description>
</proxy>
But if your JSON response object is exactly same as the one you get from the sample service that you've provided (ie., if it is an array of anonymous objects), the ESB is going to cut down the response to include only the first element (see following SOAP response).
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<position>1</position>
<team_id>10260</team_id>
<team>Manchester United</team>
<played>21</played>
<won>17</won>
<drawn>1</drawn>
<lost>3</lost>
<for>54</for>
<against>28</against>
<difference>26</difference>
<points>52</points>
<info>championsleague</info>
</soapenv:Body>
</soapenv:Envelope>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With