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

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

问题描述

我正在使用 wso2 esb 4.8.1 版本的 SOAP 来使用 API 进行转换.我有一个带有 xsi 值的肥皂请求.在我使用脚本调解器生成正确的肥皂请求并且嗯得到预期的响应之后.但我有回应的问题.因为我需要将soap响应转换为json.当我尝试跟踪序列时,um 没有使用axis2 获得正确的json 响应.如何正确将此soap响应转换为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属性.然后它将整个soap响应转换为我们预期的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天全站免登陆