How to configure Axis2's HTTP Transport Sender at Client Side?

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 Saminda Abeyruwan
  • 11 Jul, 2006

1. Timeout Configuration

Default timeout is set to 60 seconds. In user clients or stubs, one can change the timeout value to two minutes as follows:

    ...
// Set timeout in the Client
long soTimeout = 2 * 60 * 1000; // Two minutes
ServiceClient serviceClient = new ServiceClient();
Options options = new Options();
options.setTimeOutInMilliSeconds(soTimeout);
...
    ...
// Set timeout in the Stub
long soTimeout = 2 * 60 * 1000; // Two minutes
FooStub stub = new FooStub();
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(soTimeout);
...

NOTE: The above timeout configuration could only be changed in the current Axis2 SVN head, and will be available in Axis2 1.1. It is not supported by Axis2 1.0

2. HTTP Version

By default HTTP Version is set to 1.1. User can change the version either at deployment time or at runtime. Deployment time : This is done by editing Axis2.xml. One can find the following <transportSender/> element in the Axis2.xml for HTTP transport.

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

User can change it to HTTP Version 1.0 as follows:

   <transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
<parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter>
</transportSender>

Please note that the Transfer-Encoding parameter has to be removed as HTTP Version 1.0 does not support chunking. Runtime : In client or Stub, by setting the following property, user can set the HTTP transport version to 1.0.

    ...
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);
...

If the above property is set, CommonsHTTPTransportSender will disable chunking support automatically.

3. Transfer Encoding - "Chunked" Enable or Disable.

Chunking support is only available in HTTP Version 1.1. By default chunking is enabled in Axis2.xml. One can disable chunking at deployment time or at runtime. Deployment time : One can disable HTTP chunking by removing or commenting out the following element from Axis2.xml

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

Runtime : User can disable the chunking using following property set in Client or Stub,

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

4. Character set encoding.

This property encodes the payload in the HTTP POST. Default is set to UTF-8. As an Example one can set char set encoding in clients and stubs to UTF-16 as follows,

    ... 
options.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-16");
...

Applies To:

TimeOut configurations are applicable to current SVN head (Apache Axis2/Java/SNAPSHOT), while all other sections are applicable to all versions of Apache Axis2/Java.