【问题标题】:WSO2 ESB 4.5.1: SOAP to JSON transformation issuesWSO2 ESB 4.5.1:SOAP 到 JSON 的转换问题
【发布时间】:2013-06-12 12:50:50
【问题描述】:

所以我正在尝试构建基于 wsdl 的代理。此代理将侦听 hhtp/https 并将传入的 SOAP 消息转换为 JSON,通过 JMS 将其发送到端点。当然,从 JSON 到 SOAP 的返回方式也需要考虑。

有人可以帮助我如何做到这一点。我已经在 ESB 4.5.1 上尝试了示例 440,只是将“in_transform”与“out_transform”切换,还有一些在 stackoverflow 中找到的其他食谱,但似乎没有一个可以完成这项工作。在所有情况下,我都会在端点收到一条空的 JMS 消息。

这是我的代理副本

<proxy xmlns="http://ws.apache.org/ns/synapse" name="Tarjetas" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <log level="full"/>
         <property name="messageType" value="application/json" scope="axis2"/>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <xslt key="out_transform"/>
         <property name="messageType" value="text/xml" scope="axis2"/>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="jms:/FORTALEZA.BRIDGE.MOBILE.QUEUE?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue"/>
      </endpoint>
   </target>
   <publishWSDL uri="file:repository/wsdl/Debito.wsdl"/>
   <description></description>
</proxy>

这是我的 out_transform 的 localEntry

   <localEntry key="out_transform">
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
                      xmlns:m0="http://services.samples"
                      version="2.0"
                      exclude-result-prefixes="m0 fn">
         <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
         <xsl:template match="*">
            <xsl:element name="{local-name()}" namespace="http://services.samples">
               <xsl:copy-of select="attribute::*"/>
               <xsl:apply-templates/>
            </xsl:element>
         </xsl:template>
      </xsl:stylesheet>
   </localEntry>

我在axis2.xml中使用以下内容

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

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

非常感谢我能得到的所有帮助。

【问题讨论】:

    标签: json soap jms wso2 esb


    【解决方案1】:

    您需要在axis2.xml中使用以下消息格式化程序和消息生成器

        <messageFormatter contentType="application/json"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>
    
    
        <messageBuilder contentType="application/json"
                        class="org.apache.axis2.json.JSONBuilder"/>
    

    您可以在使用脚本中介构建 JSON 消息时使用 StreamFormatter。否则,上述格式化程序/构建器将满足您的要求。您需要将未注释的 StreamFormatters 注释掉。

    【讨论】:

    • 请将此标记为答案并放弃投票以使此答案在stackoverflow中轻松找到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多