WSO2 ESB JSON到SOAP

Moh*_*med 6 java rest soap wso2 wso2esb

大多数当前文档都参考了SOAP-to-JSON,我希望在使用WSO2 ESB将JSON响应对象转换为SOAP服务时是否有任何参考资料或教程.提前致谢.

样品服务:http: //api.statsfc.com/premier-league/table.json?key = free

小智 6

您可以使用类似于以下的配置来实现此目的; (我们必须将"messageType"属性设置为"text/xml",以便在响应客户端时使用SOAP消息构建器.)

<proxy xmlns="http://ws.apache.org/ns/synapse" name="JSONToSOAPService" transports="https,http">
   <target>
      <outSequence>
         <log level="full"/>
         <property name="messageType" value="text/xml" scope="axis2"/>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="http://api.statsfc.com/premier-league/table.json?key=free"/>
      </endpoint>
   </target>
   <description></description>
</proxy>
Run Code Online (Sandbox Code Playgroud)

但是,如果您的JSON响应对象与您从提供的示例服务获得的对象完全相同(即,如果它是匿名对象的数组),则ESB将减少响应以仅包括第一个元素(参见下面的SOAP响应).

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Body>
        <position>1</position>
        <team_id>10260</team_id>
        <team>Manchester United</team>
        <played>21</played>
        <won>17</won>
        <drawn>1</drawn>
        <lost>3</lost>
        <for>54</for>
        <against>28</against>
        <difference>26</difference>
        <points>52</points>
        <info>championsleague</info>
    </soapenv:Body>
</soapenv:Envelope>                    
Run Code Online (Sandbox Code Playgroud)