0

我在 WSO2 AS 有一个 AdderService。然后我在 WSO2 ESB 创建了一个带有 transports="tcp" 的代理服务:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="AdderServiceTCP" transports="tcp" statistics="disable" trace="enable" startOnLoad="true">
    <target>
      <outSequence>
         <log level="full"/>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="http://samplehost:9765/services/AdderService/"/>
      </endpoint>
   </target>
   <description></description>
</proxy>

我实现了 AdderServiceClient 类,如 Axis2 StockQuoteClient 示例。

使用 WSO2 ESB SOAP Tracer,该代理收到的请求是:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:To>tcp://localhost:55000/services/AdderServiceTCP</wsa:To>
      <wsa:MessageID>urn:uuid:b3125473-064d-4a48-9cdc-558cda8e497b</wsa:MessageID>
      <wsa:Action>urn:add</wsa:Action>
   </soapenv:Header>
   <soapenv:Body>
      <p:add xmlns:p="http://ws.apache.org/axis2">
         <p:value1>70</p:value1>
         <p:value2>150</p:value2>
      </p:add>
   </soapenv:Body>
</soapenv:Envelope>

发送给客户端的响应是:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:MessageID>urn:uuid:ed1424f9-c181-4d9c-b203-f37e88d0b0b7</wsa:MessageID>
      <wsa:Action>urn:mediateResponse</wsa:Action>
      <wsa:RelatesTo>urn:uuid:b3125473-064d-4a48-9cdc-558cda8e497b</wsa:RelatesTo>
   </soapenv:Header>
   <soapenv:Body>
      <ns:addResponse xmlns:ns="http://ws.apache.org/axis2">
         <ns:return>220</ns:return>
      </ns:addResponse>
   </soapenv:Body>
</soapenv:Envelope>

因此,AS AdderService 和代理运行正常!

但是,在 WSO2 ESB 总是会发生这种异常:

    23:01:53,254 [-] [tcp-Worker-4] INFO Proxy Service AdderServiceTCP received a new message...
    23:01:53,322 [-] [tcp-Worker-4] INFO Message To: tcp://localhost:55000/services/AdderServiceTCP
    23:01:53,322 [-] [tcp-Worker-4] INFO SOAPAction: urn:add
    23:01:53,323 [-] [tcp-Worker-4] INFO WSA-Action: urn:add
    23:01:53,323 [-] [tcp-Worker-4] INFO Forwarding the message to the anonymous endpoint of the proxy service
    23:01:53,324 [-] [tcp-Worker-4] INFO Sending message through endpoint : endpoint_1ebcda7f255c63c453527cfec85e46233762eaf68afd77ef resolving to address = http://localhost:9765/services/AdderService/
    23:01:53,325 [-] [tcp-Worker-4] INFO SOAPAction: urn:add
    23:01:53,325 [-] [tcp-Worker-4] INFO WSA-Action: urn:add
    23:01:53,371 [-] [PassThroughMessageProcessor-4] WARN ERROR_CODE : 0
    23:01:53,373 [-] [PassThroughMessageProcessor-4] WARN ERROR_MESSAGE : Unexpected error sending message back
    23:01:53,373 [-] [PassThroughMessageProcessor-4] WARN ERROR_DETAIL : org.apache.synapse.SynapseException: Unexpected error sending message back 
at org.apache.synapse.core.axis2.Axis2Sender.handleException(Axis2Sender.java:170) 
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:164) at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:236) 
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:443) 
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:166) 
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) 
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:217) 
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:722) Caused by: org.apache.axis2.AxisFault: Error while sending a TCP response 
at org.apache.axis2.transport.base.AbstractTransportSender.handleException(AbstractTransportSender.java:226) 
at org.apache.axis2.transport.tcp.TCPTransportSender.sendMessage(TCPTransportSender.java:65) at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:119) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442) 
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:161) 
... 9 more Caused by: java.net.SocketException: Socket is closed at java.net.Socket.getOutputStream(Socket.java:904) at org.apache.axis2.transport.tcp.TCPTransportSender.sendMessage(TCPTransportSender.java:63) ... 12 more
    23:01:53,378 [-] [PassThroughMessageProcessor-4] WARN ERROR_EXCEPTION : org.apache.synapse.SynapseException: Unexpected error sending message back
    23:01:53,378 [-] [PassThroughMessageProcessor-4] WARN FaultHandler : org.apache.synapse.mediators.MediatorFaultHandler@111ce13
    23:01:53,379 [-] [PassThroughMessageProcessor-4] WARN Executing fault handler mediator : fault
    23:01:53,379 [-] [PassThroughMessageProcessor-4] INFO Start : Sequence <fault>
    23:01:53,380 [-] [PassThroughMessageProcessor-4] INFO Sequence <SequenceMediator> :: mediate()
    23:01:53,392 [-] [PassThroughMessageProcessor-4] ERROR Error while building message
    23:15:56,619 [-] [http-nio-9443-exec-26] INFO Building Axis service for Proxy service : AdderServiceTCP
    23:15:56,620 [-] [http-nio-9443-exec-26] INFO Loading the WSDL : <Inlined>
    23:15:56,620 [-] [http-nio-9443-exec-26] INFO Did not find a WSDL. Assuming a POX or Legacy service
    23:15:56,620 [-] [http-nio-9443-exec-26] INFO Exposing transports : [tcp]
    23:15:56,621 [-] [http-nio-9443-exec-26] INFO Adding service AdderServiceTCP to the Axis2 configuration
    23:15:56,675 [-] [http-nio-9443-exec-26] INFO Successfully created the Axis2 service for Proxy service : AdderServiceTCP 

客户显示:

     [java] 13/04/27 23:48:58 ERROR tcp.TCPTransportSender: Error while processi
ng response
     [java] org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxEOFException:
Unexpected EOF in prolog
     [java]  at [row,col {unknown-source}]: [1,0]
     [java]     at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBui
lder.java:296)
     [java]     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSO
APEnvelope(StAXSOAPModelBuilder.java:204)
     [java]     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init
>(StAXSOAPModelBuilder.java:154)
     [java]     at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAP
ModelBuilder(AbstractOMMetaFactory.java:73)
     [java]     at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPMode
lBuilder(AbstractOMMetaFactory.java:79)
     [java]     at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilde
r(OMXMLBuilderFactory.java:196)
     [java]     at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuil
der.java:55)
     [java]     at org.apache.axis2.transport.TransportUtils.createDocumentEleme
nt(TransportUtils.java:179)
     [java]     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(T
ransportUtils.java:145)
     [java]     at org.apache.axis2.transport.tcp.TCPTransportSender.waitForRepl
y(TCPTransportSender.java:94)
     [java]     at org.apache.axis2.transport.tcp.TCPTransportSender.sendMessage
(TCPTransportSender.java:54)
     [java]     at org.apache.axis2.transport.base.AbstractTransportSender.invok
e(AbstractTransportSender.java:112)
     [java]     at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
     [java]     at org.apache.axis2.description.OutInAxisOperationClient.send(Ou
tInAxisOperation.java:398)
     [java]     at org.apache.axis2.description.OutInAxisOperationClient$NonBloc
kingInvocationWorker.run(OutInAxisOperation.java:434)
     [java]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolE
xecutor.java:1110)
     [java]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPool
Executor.java:603)
     [java]     at java.lang.Thread.run(Thread.java:722)
     [java] Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prol
og
     [java]  at [row,col {unknown-source}]: [1,0]
     [java]     at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanne
r.java:677)
     [java]     at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader
.java:2116)
     [java]     at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamR
eader.java:2022)
     [java]     at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java
:1114)
     [java]     at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.nex
t(XMLStreamReaderWrapper.java:225)
     [java]     at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamR
eaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
     [java]     at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.nex
t(XMLStreamReaderWrapper.java:225)
     [java]     at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StA
XOMBuilder.java:681)
     [java]     at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBui
lder.java:214)
     [java]     ... 17 more
     [java] 13/04/27 23:48:58 ERROR tcp.TCPTransportSender: Error while sending
a TCP request
     [java] org.apache.axis2.AxisFault: Error while processing response
     [java]     at org.apache.axis2.transport.base.AbstractTransportSender.handl
eException(AbstractTransportSender.java:226)
     [java]     at org.apache.axis2.transport.tcp.TCPTransportSender.waitForRepl
y(TCPTransportSender.java:99)
     [java]     at org.apache.axis2.transport.tcp.TCPTransportSender.sendMessage
(TCPTransportSender.java:54)
     [java]     at org.apache.axis2.transport.base.AbstractTransportSender.invok
e(AbstractTransportSender.java:112)
     [java]     at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
     [java]     at org.apache.axis2.description.OutInAxisOperationClient.send(Ou
tInAxisOperation.java:398)
     [java]     at org.apache.axis2.description.OutInAxisOperationClient$NonBloc
kingInvocationWorker.run(OutInAxisOperation.java:434)
     [java]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolE
xecutor.java:1110)
     [java]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPool
Executor.java:603)
     [java]     at java.lang.Thread.run(Thread.java:722)
     [java] Caused by: org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxEOF
Exception: Unexpected EOF in prolog
     [java]  at [row,col {unknown-source}]: [1,0]
     [java]     at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBui
lder.java:296)
     [java]     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSO
APEnvelope(StAXSOAPModelBuilder.java:204)
     [java]     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init
>(StAXSOAPModelBuilder.java:154)
     [java]     at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAP
ModelBuilder(AbstractOMMetaFactory.java:73)
     [java]     at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPMode
lBuilder(AbstractOMMetaFactory.java:79)
     [java]     at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilde
r(OMXMLBuilderFactory.java:196)Error inside callback : org.apache.axis2.AxisFaul
t: Error while sending a TCP request
     [java]
     [java]     at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuil
der.java:55)
     [java]     at org.apache.axis2.transport.TransportUtils.createDocumentEleme
nt(TransportUtils.java:179)
     [java]     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(T
ransportUtils.java:145)
     [java]     at org.apache.axis2.transport.tcp.TCPTransportSender.waitForRepl
y(TCPTransportSender.java:94)
     [java]     ... 8 more
     [java] Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prol
og
     [java]  at [row,col {unknown-source}]: [1,0]
     [java]     at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanne
r.java:677)
     [java]     at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader
.java:2116)
     [java]     at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamR
eader.java:2022)
     [java]     at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java
:1114)
     [java]     at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.nex
t(XMLStreamReaderWrapper.java:225)
     [java]     at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamR
eaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
     [java]     at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.nex
t(XMLStreamReaderWrapper.java:225)
     [java]     at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StA
XOMBuilder.java:681)
     [java]     at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBui
lder.java:214)
     [java]     ... 17 more

**我做错了什么?

谢谢你帮助我。**

4

3 回答 3

1

您是否在客户端启用了传输接收器配置?看起来客户端没有 Tcp 的传输侦听器。

你需要在axis2.xml中有这样的东西。

<transportReceiver name="tcp"
                       class="org.apache.axis2.transport.tcp.TCPServer">
        <parameter name="port">6061</parameter>
于 2013-04-28T05:40:09.383 回答
0

Shelan.

At client side I have been enabled TCP transport receiver and sender:

<transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportListener">
  <parameter name="transport.tcp.port">57000</parameter>
</transportReceiver>
<transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/>

However, using wireshark to monitoring the network communication, that TCP port is never used. I believe that enabling TCP listener at client side is not necessary. Right?

Thank you.

于 2013-05-01T18:40:04.707 回答
0

雪兰。

根据您的回答,我在客户端将 useSeparareListener 属性设置为 true。现在,一切正常!

于 2013-05-01T19:16:06.723 回答