如何在WSO2esb中将具有xsi值的SOAP响应转换为json [英] How to convert SOAP response with xsi values to json in WSO2esb

查看:127
本文介绍了如何在WSO2esb中将具有xsi值的SOAP响应转换为json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用wso2 esb 4.8.1版本的SOAP,以使用API​​进行其余转换.我有一个xsi值的肥皂请求.在使用脚本中介器生成正确的肥皂请求后,um获得了预期的响应.但是我有一个回应问题.因为我需要将soap响应转换为json.当我尝试遵循顺序um时,使用axis2无法获得正确的json响应.如何将这个肥皂响应正确转换为json?

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?

这是肥皂反应.

    <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>

这是我得到的回应

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

这是我的出场顺序

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

非常欢迎您回答所有问题.

All your answers are highly welcome.

推荐答案

最后,我找到了解决该问题的方法.通常情况下,我们使用

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>

但是,这个axis2属性无法将复杂的soap响应转换为json(例如xsi). 为此,需要使用以下axis2属性.然后按照我们的预期将整个肥皂响应转换为Json.

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>

这是我的全部结果.

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

这篇关于如何在WSO2esb中将具有xsi值的SOAP响应转换为json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆