wso2ESB中JSON数据的消息中继

时间:2012-07-12 07:22:02

标签: json wso2 wso2esb

我正在尝试使用wso2ESB构建一个简单的POC。我已经使用Alfresco服务http://www.alfresco.com/

创建了一个简单的代理服务传递

问题是我没有获得完整的JSON数据。我读过它与axis2-JSON有关,当它在根目录中有JSONArray时会导致问题。所以我决定使用消息中继。

WSO2 ESB Unable to convert complete JSON data to XML

我已经按照文档中的描述编辑了axis2.xml,因此添加了以下行

<messageFormatter contentType="application/json"
                        class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageBuilder contentType="application/xml"
                class="org.apache.axis2.builder.ApplicationXMLBuilder"/>

但是当我尝试通过firefox REST插件使用代理服务器重新启动服务器后,ESB会抛出以下异常

    [2012-07-12 10:02:29,125]  WARN - ClientWorker Unexpected response received. HTTP response co
de : 405 HTTP status : Method Not Allowed exception : SOAP message MUST NOT contain a Documen
t Type Declaration(DTD)
[2012-07-12 10:02:29,125] ERROR - NativeWorkerPool Uncaught exception
java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMTextImpl cannot be cast to org.
apache.axiom.om.OMElement
        at org.apache.synapse.util.MessageHelper.cloneSOAPFault(MessageHelper.java:441)
        at org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:254)
        at org.apache.synapse.core.axis2.SOAPUtils.convertSOAP11toSOAP12(SOAPUtils.java:95)
        at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbac
kReceiver.java:323)
        at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackRecei
ver.java:160)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
        at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:275)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.ja
va:173)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)

是什么原因引起的?问题是ESB仍然试图转换JSON对象而不是尝试转发它吗?

在解析这些JSON对象时是否有另一种解决方法(即将人工根添加到JSON对象?)

1 个答案:

答案 0 :(得分:1)

在构建器中,您需要将application / json设置为使用org.wso2.carbon.relay.BinaryRelayBuilder。