Question

I'm having issues accessing a web service provided by a third party. Looking at the Axis2 wire trace I can see \r\n3ff8\r\n in the middle of my the XML tags coming back which is causing Axis2 to have a hissy fit when it tries to parse them.

As far as I can tell this has something to do with HTTP 1.1 chunking which Axis2 isn't handling very well.

The issue I'm having is Identical to the issue in this forum post

How can I change the my webservice code to make it use HTTP 1.0 to avoid the chunking issue? As far as I can tell Axis defaults to CommonsHTTPSender anyway so I'm unsure why the forum post linked above suggested changing to that.

Alternatively is there a better way to solve this problem?

Was it helpful?

Solution

You can directly turn off chunking:

stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);

You can also control both of these things through the axis2.xml config file, if you'd prefer. Find the following section:

<transportSender name="http"
    class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
    <parameter name="PROTOCOL">HTTP/1.1</parameter>
    <parameter name="Transfer-Encoding">chunked</parameter>
</transportSender>

You can change the PROTOCOL parameter to "HTTP/1.0", or remove the Transfer-Encoding parameter to disable chunking.

OTHER TIPS

Found out how to do it, get the stub object that you you will use to call the service and add the following code after it:

stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
                org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top