Anushka Ekanayake Anushka Ekanayake - 1 year ago 315
JSON Question

How to convert SOAP response with xsi values to json in WSO2esb

I'm using wso2 esb 4.8.1 version for SOAP to rest conversion with as API. I have a soap request with xsi values. After I generate the proper soap request with script mediator and um getting an expected response. But I have an issue with response. Because I need t convert the soap response into json. When I tried with following out sequence um not getting the proper json response with axis2. How can I convert this soap response into json properly?

This it the soap response.

<soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi="">
<ns1:easyDownloadResponse xmlns:ns1="" soapenv:encodingStyle="">
<easyDownloadReturn href="#id0"/>
<multiRef xmlns:soapenc="" xmlns:ns2="" id="id0" soapenc:root="0" soapenv:encodingStyle="" 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"/>

This is the response which i'm getting


This is my out sequence

<outSequence xmlns="">
<property name="messageType" value="application/json" scope="axis2" type="STRING"></property>

All your answers are highly welcome.

Answer Source

Finally I found the solution for the issue. In the normal case we use

<property name="messageType" value="application/json" scope="axis2" type="STRING"></property>

But this axis2 property cannot convert the complex soap response into json such as with xsi. For that need to use the following axis2 property. Then it converts the entire soap response into Json as we expected.

 <property name="messageType" value="application/json/badgerfish" scope="axis2" type="STRING"></property>

This is my full outsequence.

<outSequence xmlns="">
   <property name="messageType" value="application/json/badgerfish" scope="axis2" type="STRING"></property>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download