Extraneous Characters Appearing in the Axis2 Generated SOAP Messages

Archived Content
This article is provided for historical perspective only, and may not reflect current conditions. Please refer to relevant product page for more up-to-date product information and resources.
  • By wso2 wso2
  • 11 Mar, 2007

Answer: These characters (see the example message traces given below) appear due to HTTP Chunking. This is a feature introduced by the HTTP 1.1 specification [2] to efficiently transfer large HTTP messages without buffering the whole message in the memory. HTTP Chunking transfers the message by breaking it into chunks. If you have a closer look at the message, you will notice a relationship between the extra numbers that appear and the message size (or specifically with the size of the chunks). You will also notice the HTTP header "Transfer-Encoding: chunked" and the absence of the content-length HTTP header. It is advised to use HTTP Chunking with Apache Axis2 whenever possible, especially if you are dealing with large messages like messages with attachments.

HTTP Chunking might not be supported by some (older) servers or clients, which do not support HTTP 1.1. Upon receiving a "chunked" message, those servers might fail while parsing the message. Hence an error message appears. In order to communicate with them, you can disable the HTTP Chunking in Apache Axis2 as follows.

At deployment, commenting out or removing the following in axis2.xml

<parameter name="Transfer-Encoding">chunked</parameter>

At runtime, using Axis2 client side options object

options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);

Example chunked message snapshot 1:

POST /axis2/services/EchoXMLService/echoOMElement HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "urn:anonOutInOp"
User-Agent: Axis2
Transfer-Encoding: chunked

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="https://schemas.xmlsoap.org/soap/envelope/">
<ns1:echoOM xmlns:ns1="https://org.apache.axis2/xsd">
<ns1:myValue>Isaac Asimov, The Foundation Trilogy</ns1:myValue>

Example chunked message snapshot 2:

POST /axis2/services/EchoXMLService/echoOMElement HTTP/1.1
Content-Type: multipart/related; boundary=MIMEBoundary; ..............;
User-Agent: Axis2
Transfer-Encoding: chunked

content-type: application/xop+xml; charset=UTF-8; type="application/soap+xml"
content-transfer-encoding: binary
content-id: <0.urn:uuid:47174CDCBA7B918E391172168040614@apache.org>

<?xml version='1.0' encoding='UTF-8'?>
content-type: image/jpeg
content-transfer-encoding: binary
content-id: <1.urn:uuid:47174CDCBA7B918E391172168040620@apache.org>


Applies To:

Apache Axis2/Java, 1.0 and above.

More Information:

[1] How to configure Axis2's HTTP Transport Sender at Client Side- https://wso2.org/library/209

[2] Hypertext Transfer Protocol HTTP/1.1 - Section 3.6:Transfer Codings https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html