0

我将 WSO2 ESB 4.7.0 与 ActiveMQ 一起使用。我正在尝试按照这个wso2 文档实现一个简单的存储和转发配置。

这是我用来存储在 JMS 和转发中的代理:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="testJMSStorenFwd"
       transports="http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence onError="fault">
         <property name="messageType" value="application/json" scope="axis2"/>
         <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
         <property name="OUT_ONLY" value="true"/>
         <log level="full"/>
         <property name="target.endpoint" value="JMSRcvEndPoint" format="soap11"/>
         <store messageStore="FMSReadings"/>
         <!--send>
            <endpoint key="JMSRcvEndPoint" format="soap11"/>
         </send-->
         <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
</proxy>

这是消息最终应该转发到的端点:

<?xml version="1.0" encoding="UTF-8"?>
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="JMSRcvEndPoint">
   <address uri="http://kk1:8282/services/testJMSRcvProxy" format="soap11"/>
</endpoint>

这是接收转发消息的代理(它只是记录此测试接收到的消息):

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="testJMSRcvProxy"
       transports="http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence onError="fault">
        <property name="messageType" value="application/json" scope="axis2"/>
        <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
        <log level="full"/>
        <drop/>
      </inSequence>
      <outSequence>
         <drop/>
      </outSequence>
   </target>
</proxy>

这是我的消息库:

<?xml version="1.0" encoding="UTF-8"?>
<messageStore xmlns="http://ws.apache.org/ns/synapse"
              class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore"
              name="FMSReadings">
   <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
   <parameter name="store.jms.cache.connection">false</parameter>
   <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
   <parameter name="store.jms.JMSSpecVersion">1.1</parameter>
</messageStore>

这是我的 MessageProcessor :

<?xml version="1.0" encoding="UTF-8"?>
<messageProcessor xmlns="http://ws.apache.org/ns/synapse"
                  class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
                  name="fwdTotestJMSRcvProxy"
                  messageStore="FMSReadings">
   <parameter name="interval">1000</parameter>
</messageProcessor>

我正在使用带有非常基本 JSON 的简单 curl 命令来测试此设置,如下所示:

curl -v -H "Accept: application/json" -H "Content-Type:application/json" -d '{"mail":"faisal.shaik@youtility.in"}' http://kk1:8282/services/testJMSStorenFwd

当我运行此消息时,设置会存储和转发消息(我可以从 ActiveMQ Web UI 验证消息已入队和出队),但在 ESB 日志中出现以下错误:

[2013-08-27 14:24:44,052]  INFO -  To: /services/testJMSStorenFwd, MessageID: urn:uuid:bb553e52-ee61-4d15-8c1f-19be1356c8e0, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><mail>faisal.shaik@youtility.in</mail></soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
[2013-08-27 14:24:44,085] ERROR -  Error building message {org.apache.synapse.transport.passthru.util.DeferredMessageBuilder}
org.apache.axis2.AxisFault: Failed to convert JSON to XML payload. Expected a ',' or '}' at character 50 of { "xmlPayload" : <mail>faisal.shaik@youtility.in</mail>}
    at org.apache.axis2.json.JSONBuilder.processDocument(JSONBuilder.java:86)
    at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)

如果您在上面的 testJMSStorenFwd 代理中注意到我有一个注释掉的发送部分。如果我取消注释并注释掉

<property name="target.endpoint" value="JMSRcvEndPoint" format="soap11"/>
         <store messageStore="FMSReadings"/>

部分,我将 json 正确转换为 xml 并在日志中进行以下输出:

[2013-08-27 14:53:27,333]  INFO -  To: /services/testJMSStorenFwd, MessageID: urn:uuid:e482aba1-98a9-4181-9c8e-c5110dcefd09, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><mail>faisal.shaik@youtility.in</mail></soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
[2013-08-27 14:53:27,346]  INFO -  To: /services/testJMSRcvProxy, MessageID: urn:uuid:e6da7131-60ec-4c92-b204-e3843f7e6e91, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Envelope><soapenv:Body><mail>faisal.shaik@youtility.in</mail></soapenv:Body></soapenv:Envelope></soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}

从上面可以看出,使用相同设置为消息存储和消息处理器机制提供的相同输入会导致 JSON 到 XML 的转换错误。

这是 wso2 esb MessageStore 和/或 MessageProcessor 中的错误还是我做错了什么?有没有办法摆脱我在使用这个 JMS 存储和转发时遇到的错误而不求助于脚本中介?

4

1 回答 1

0

好像您正在尝试将 REST 实施到 SOAP 场景。http://docs.wso2.org/display/ESB470/Using+REST+with+a+Proxy+Service#UsingRESTwithaProxyService-RESTClientandSOAPService

尝试messageType从您的代理中删除该属性。

于 2013-08-27T10:22:09.390 回答