我有一个基于HTTP方法的代理服务将请求发送到由WSO2 Application Server托管的应用程序或WSO2数据服务服务器上的数据服务。
某些PUT
操作不需要请求体,因为它们只是根据URI语义更改了某些内容,但是当我没有有效负载时,我无法使其工作。
服务看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="IntegrationProxy" transports="http https" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="original.content-type" expression="$trp:Content-Type" type="STRING"/>
<property name="FORCE_POST_PUT_NOBODY" value="true" scope="axis2" type="BOOLEAN"/>
<property name="Content-Type" value="get-property('original.content-type')" scope="transport"/>
<property name="as.host" value="http://as-host:9763" type="STRING"/>
<property name="dss.host" value="http://dss-host:9763" type="STRING"/>
<property name="uri.var.as.service.url" expression="fn:concat(get-property('as.host'), '/rest/integracao')"/>
<property name="uri.var.dss.service.url" expression="fn:concat(get-property('dss.host'), '/services/Integrations')"/>
<log level="custom" separator="\n">
<property name="ProxyNameIn" value="IntegrationProxy - inSequence"/>
</log>
<log level="custom" separator="\n">
<property name="Original-Content-Type" expression="get-property('original.content-type')"/>
<property name="Content-Type" expression="get-property('Content-Type')"/>
<property name="FORCE_POST_PUT_NOBODY" expression="$axis2:FORCE_POST_PUT_NOBODY"/>
<property name="Method" expression="$axis2:HTTP_METHOD"/>
</log>
<switch source="$axis2:HTTP_METHOD">
<case regex="GET">
<property name="called.url" expression="fn:concat(get-property('uri.var.dss.service.url'), $axis2:REST_URL_POSTFIX)"/>
<send>
<endpoint>
<http uri-template="{uri.var.dss.service.url}" method="$axis2:HTTP_METHOD"/>
</endpoint>
</send>
</case>
<default>
<property name="called.url" expression="fn:concat(get-property('uri.var.as.service.url'), $axis2:REST_URL_POSTFIX)"/>
<send>
<endpoint>
<http uri-template="{uri.var.as.service.url}" method="$axis2:HTTP_METHOD"/>
</endpoint>
</send>
</default>
</switch>
</inSequence>
<outSequence>
<log level="custom" separator="\n">
<property name="CalledURL" expression="get-property('called.url')" />
<property name="ProxyNameOut" value="IntegrationProxy - outSequence"/>
</log>
<send />
</outSequence>
</target>
</proxy>
即使使用FORCE_POST_PUT_NOBODY
,我们也会收到org.apache.axis2.AxisFault: No JSON payload provided
。在完整的堆栈跟踪下方:
wso2_esb_apis | [2016-12-20 13:43:04,954] ERROR - JsonUtil #newJsonPayload. Could not save JSON payload. Invalid input stream found. MessageID: urn:uuid:222c9ec6-6085-4344-8622-d7ff76fc7d13
wso2_esb_apis | [2016-12-20 13:43:04,955] ERROR - DeferredMessageBuilder Error building message
wso2_esb_apis | org.apache.axis2.AxisFault: No JSON payload provided.
wso2_esb_apis | at org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:52)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:138)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:133)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:98)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
wso2_esb_apis | at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
wso2_esb_apis | at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:185)
wso2_esb_apis | at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:317)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:363)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)
wso2_esb_apis | at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
wso2_esb_apis | at java.lang.Thread.run(Thread.java:745)
wso2_esb_apis | [2016-12-20 13:43:04,956] ERROR - RelayUtils Error while building Passthrough stream
wso2_esb_apis | org.apache.axis2.AxisFault: No JSON payload provided.
wso2_esb_apis | at org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:52)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:138)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:133)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:98)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
wso2_esb_apis | at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
wso2_esb_apis | at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:185)
wso2_esb_apis | at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:317)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:363)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)
wso2_esb_apis | at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
wso2_esb_apis | at java.lang.Thread.run(Thread.java:745)
wso2_esb_apis | [2016-12-20 13:43:04,958] ERROR - SequenceMediator Error while building message
wso2_esb_apis | org.apache.axis2.AxisFault: Error while building Passthrough stream
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:283)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:142)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:98)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
wso2_esb_apis | at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
wso2_esb_apis | at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:185)
wso2_esb_apis | at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:317)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:363)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)
wso2_esb_apis | at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
wso2_esb_apis | at java.lang.Thread.run(Thread.java:745)
wso2_esb_apis | Caused by: org.apache.axis2.AxisFault: No JSON payload provided.
wso2_esb_apis | at org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:52)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:138)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:133)
wso2_esb_apis | ... 13 more
wso2_esb_apis | [2016-12-20 13:43:04,960] INFO - LogMediator To: /services/SGTIntegracoesProxy/atendimentos/39679/aceito?idregional=11, MessageID: urn:uuid:222c9ec6-6085-4344-8622-d7ff76fc7d13, Direction: request, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Error while building message, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>
像{}
之类的机构工作正常,但我寻找一个“透明”的解决方案,没有这样的解决方法。有没有人有这样的问题?
更新:这适用于WSO2 ESB 5.0.0:https://wso2.org/jira/browse/ESBJAVA-4270。有没有人“轻松”升级到5.0.0?或者更好的是,有没有人知道这个补丁,没有其他变化?