Friday, July 22, 2016

[WSO2][ESB] Converting SOAP response to JSON and missing a part

Environment: ESB 4.9.0
                         Java 1.8.0
             
Preconditions: Create a proxy which will convert SOAP response into JSON format (within the out sequence)

Sample out sequence:

<outSequence xmlns="http://ws.apache.org/ns/synapse">
   <property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
   <send></send>
</outSequence> 

Error: It will only convert part of the response into JSON.

Sample Response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"       xmlns:xsd="http://www.w3.org/2001/XMLSchema"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:easyDownloadResponse xmlns:ns1="http://usermanage.ivas.huawei.com" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<easyDownloadReturn href="#id0"/>
</ns1:easyDownloadResponse>
<multiRef xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://response.usermanage.ivas.huawei.com" id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:EasyDownloadResp">
<eventClassName xsi:type="xsd:string" xsi:nil="true"/>
<failedResources xsi:type="soapenc:Array" xsi:nil="true"/>
<operationID xsi:type="xsd:long">0</operationID>
<resultCode xsi:type="xsd:int">0</resultCode>
<resultInfo xsi:type="xsd:string" xsi:nil="true"/>
<returnCode xsi:type="xsd:string">000000</returnCode>
<toneTransactionID xsi:type="soapenc:Array" xsi:nil="true"/>
<transactionID xsi:type="xsd:string" xsi:nil="true"/>
</multiRef>
</soapenv:Body> </soapenv:Envelope> 

Converted JSON :

{"easyDownloadResponse":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","easyDownloadReturn":{"@href":"#id0"}}}

Solution:

Add JSON conversion property as follows:

<outSequence xmlns="http://ws.apache.org/ns/synapse">
   <property name="messageType" value="application/json/badgerfish" scope="axis2" type="STRING"></property>
   <send></send>
</outSequence>


No comments:

Post a Comment