如何在WSO2esb中将具有xsi值的SOAP响应转换为json

阿努什卡·埃卡纳亚克(Anushka Ekanayake)

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

这是肥皂反应。

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

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

阿努什卡·埃卡纳亚克(Anushka Ekanayake)

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

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

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章