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

时光总嘲笑我的痴心妄想 提交于 2019-12-06 11:37:45

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="http://ws.apache.org/ns/synapse">
   <property name="messageType" value="application/json/badgerfish" scope="axis2" type="STRING"></property>
   <send></send>
</outSequence>
Dilshani Subasinghe

You can try payload mediator to get exact json format 1. But still you may have to uncomment the following lines in

$ESB_HOME/repository/conf/axis2/axis2.xml

<!--messageFormatter contentType="application/json"
class="org.apache.axis2.json.JSONStreamFormatter"/-->

<!--messageBuilder contentType="application/json"
class="org.apache.axis2.json.JSONStreamBuilder"/-->

By default, JSON messages are converted to XML when they are received by the PayloadFactor mediator. However, if you enable the JSON stream formatter and builder, incoming JSON messages are left in JSON format.

And also you can use script mediator again (In outsequence) to modify your json response. Refer this sample

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!