WSO2 ESB 4.9 - Send mediator causing errors

南笙酒味 提交于 2019-12-12 02:24:34

问题


I've been working on a resource over the last few days (I'm very new to WSO2 so I'm still pretty slow) and when I submit a request to it via SoapUI, it logs everything it should up to the <send/> mediator and then dumps the following errors:

ERROR -  Failed to submit the response {org.apache.synapse.transport.passthru.PassThroughHttpSender}
java.lang.NullPointerException
	at org.apache.synapse.transport.passthru.util.SourceResponseFactory.create(SourceResponseFactory.java:64)
	at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:462)
	at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:267)
	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
	at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:212)
	at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:444)
	at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:102)
	at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
	at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:277)
	at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:679)
	at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:244)
	at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:529)
	at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:172)
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
	at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:247)
	at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

[2015-12-10 13:11:00,508] ERROR -  Access-Control-Allow-Credentials:true,Cache-Control:no-cache,Content-Type:application/json,Etag:W/"2-mZFLkyvTelC5g8XnyQrpOw",Expires:-1,Pragma:no-cache,Vary:Origin, X-HTTP-Method-Override,Via:1.1 vegur,X-Content-Type-Options:nosniff,X-Powered-By:Express,<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonObject><TYPE></TYPE><NODE></NODE><STATUS>200 [OK]</STATUS></jsonObject></soapenv:Body></soapenv:Envelope> Unexpected error sending message back {org.apache.synapse.core.axis2.Axis2Sender}
org.apache.axis2.AxisFault: Failed to submit the response
	at org.apache.synapse.transport.passthru.PassThroughHttpSender.handleException(PassThroughHttpSender.java:610)
	at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:269)
	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
	at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:212)
	at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:444)
	at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:102)
	at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
	at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:277)
	at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:679)
	at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:244)
	at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:529)
	at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:172)
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
	at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:247)
	at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
	at org.apache.synapse.transport.passthru.util.SourceResponseFactory.create(SourceResponseFactory.java:64)
	at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:462)
	at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:267)
	... 16 more

The resource takes in a JSON submission from SoapUI, like the one below:

{"tests":[{"type":"DSS","node":"2"}]}

From that submission, it draws the type of system to test (DSS) and which node on that system to test (2). In this case, it runs the sequence below, in order to test node 2 on the DSS we're running:

<sequence name="dss_node_2_seq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
  <log level="custom">
    <property name="[[ SQNC ]]" value="STARTING DSS2 SEQUENCE"/>
  </log>
  <call>
    <endpoint key="dss_node_2"/>
  </call>
</sequence>

This sequence obviously then calls the dss_node_2 endpoint which at the moment points to a typicode page with some templated valid JSON:

<endpoint name="dss_node_2" xmlns="http://ws.apache.org/ns/synapse">
  <http method="post" trace="disable" uri-template="http://jsonplaceholder.typicode.com/posts/1"/>
</endpoint>

I have put the resource into a Kobra.io page so you can see it and make any changes that are necessary. I'm currently testing it on just DSS at the moment but there are several types that are possible, each with a set number of nodes.


If anyone could suggest why it's throwing these errors at me and how to fix it, that'd be really helpful and much appreciated as I've been stuck on this for hours now and it's becoming quite the frustration!


回答1:


Try using send Mediator instead of call mediator ,Which will wait for the entire flow to complete, send may help you to send the response immediately.

 <send>
<endpoint key="dss_node_2"/>
</send>  



回答2:


Try to move this part just before send mediator (used in your API to send back a response to the caller) (it must not be defined before call mediator) :

<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
      <header action="remove" name="To" scope="default"/>
      <property name="RESPONSE" scope="default" type="STRING" value="true"/>
      <property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>



回答3:


Try using respond mediator, <respond/> instead of <send/>

Also, verify the payload to contain the proper headers write before the send. You can do this with a <log level="full"/>



来源:https://stackoverflow.com/questions/34203258/wso2-esb-4-9-send-mediator-causing-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!