0

下面的配置我已经完成了。创建了发送 JSON 输入和预期 JSON O/P 的代理,但没有在错误序列中返回 JSON。

<proxy xmlns="http://ws.apache.org/ns/synapse" name="Get_Asset_Mobile" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence onError="fault">
         <property name="CONTENT_TYPE" value="application/json" scope="axis2" type="STRING"/>
         <payloadFactory>
            <format>
               <Select_Mobile_Asset_Op xmlns=""/>
            </format>
         </payloadFactory>
         <send receive="Asset_Mobile_seq">
            <endpoint>
               <address uri="http://localhost:9764/services/masset_DataService/" format="soap11"/>
            </endpoint>
         </send>
         <property xmlns:ns="http://org.apache.synapse/xsd" name="message" expression="get-property('ERROR_MESSAGE')"/>
         <property xmlns:ns="http://org.apache.synapse/xsd" name="code" expression="get-property('ERROR_CODE')"/>
         <log level="full"/>
      </inSequence>
      <outSequence onError="fault">
         <property name="CONTENT_TYPE" value="application/json" scope="axis2" type="STRING"/>
         <log level="full"/>
         <drop/>
      </outSequence>
   </target>
   <description></description>
</proxy>

上面一个是代理,下面是 FAULT 序列。

<sequence xmlns="http://ws.apache.org/ns/synapse" name="fault">
   <property name="CONTENT_TYPE" value="application/json" scope="axis2" type="STRING"/>
   <property xmlns:ns="http://org.apache.synapse/xsd" name="message" expression="get-property('ERROR_MESSAGE')"/>
   <property xmlns:ns="http://org.apache.synapse/xsd" name="code" expression="get-property('ERROR_CODE')"/>
   <payloadFactory>
      <format>
         <Body xmlns="">
            <Exception>$1</Exception>
            <Status>$2</Status>
            <Total>0</Total>
         </Body>
      </format>
      <args>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('message')"/>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('code')"/>
      </args>
   </payloadFactory>
   <send/>
   <log level="full"/>
</sequence>

但它没有从客户端反映在 WSO2 ESB 终端消息中显示正确的消息,如下所示:

[2013-02-07 17:13:49,603] ERROR - ClientUtils The system cannot infer the transport information from the /services/Get_Asset_Mobile URL.
[2013-02-07 17:13:49,604] ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault: The system cannot infer the transport information from the /services/Get_Asset_Mobile URL.
    at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:81)
    at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:123)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:445)
    at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:57)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:286)
    at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:92)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
    at org.apache.synapse.mediators.MediatorFaultHandler.onFault(MediatorFaultHandler.java:81)
    at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:54)
    at org.apache.synapse.endpoints.AbstractEndpoint.invokeNextFaultHandler(AbstractEndpoint.java:564)
    at org.apache.synapse.endpoints.AbstractEndpoint.onFault(AbstractEndpoint.java:413)
    at org.apache.synapse.endpoints.AddressEndpoint.onFault(AddressEndpoint.java:43)
    at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:102)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:237)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:160)
    at org.apache.synapse.transport.nhttp.ClientHandler$1.run(ClientHandler.java:494)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
[2013-02-07 17:13:49,604]  INFO - LogMediator To: /services/Get_Asset_Mobile, MessageID: urn:uuid:793b3646-8342-4d75-a9b3-d41dc0ab5a2d, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><Body><Exception>Connection refused or failed for : localhost/127.0.0.1:9764, IO Exception occured : Connection refused</Exception><Status>101503</Status><Total>0</Total></Body></soapenv:Body></soapenv:Envelope>

两者都工作正常,但它没有反映客户端。我关闭端点(wso2 DSS)并跟踪错误..请帮助我。

4

1 回答 1

0

我认为你应该拥有的是:

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

而不是有 CONTENT_TYPE。似乎没有定义这个属性。如果您的客户端是 REST/JSON 客户端,那么在 inSequence 中包含它就足够了。

于 2013-02-10T18:17:11.067 回答