0

I have a proxy service that based on HTTP Method sends the request to an application hosted by WSO2 Application Server or to a data service on WSO2 Data Services Server.

Some PUT operations needs no request body, since they just change something based on URI semantics, but I can't getting this works when I PUT without a payload.

The service look like this:

<?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>

Even using FORCE_POST_PUT_NOBODY we're receiving org.apache.axis2.AxisFault: No JSON payload provided. Below the full stack trace:

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 version: 4.9.0
  • Java:
    • java version "1.7.0_79"
    • Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
    • Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

With a body like {} works fine, but I look for a "transparent" solution, without such workaround. Does anyboby have an issue like that?

UPDATE: this works with WSO2 ESB 5.0.0: https://wso2.org/jira/browse/ESBJAVA-4270. Does anyone upgraded "easily" to 5.0.0? Or better, does anyone knows a patch to this, without other changes?

Community
  • 1
  • 1
Bruno Ribeiro
  • 5,956
  • 5
  • 39
  • 48
  • What is the content-type of your request? – Bee Dec 20 '16 at 17:47
  • @Bhathiya in this case, `application/json`, but I handle othe content types, since is a pass through – Bruno Ribeiro Dec 20 '16 at 19:36
  • Did you try with content-type application/x-www-form-urlencoded since there is no payload ? – Jenananthan Dec 22 '16 at 07:01
  • @Jenananthan to call ESB not yet, but I don't know if is an alternative, since clients should change how to consume the API as the real endpoint, out of my control. This problem happen on API Manager too, this ESB proxy is the implementation to an API on APIM. Problem is on `wso2-synapse`, so I don't know if is as good idea change update so many applications because this. As said `FORCE_POST_PUT_NOBODY` with ESB 5.0.0 works well, so I'm testing alternatives to simplify the changes on production. – Bruno Ribeiro Dec 22 '16 at 10:33

0 Answers0