This document is all about HTTP sender and HTTP receiver, and how they work in Axis2.
Send your feedback or questions to: axis-dev@ws.apache.org. Prefix subject with [Axis2]. To subscribe to mailing list see here.
This is the default transport sender that is used in Server API as well as Client API. As the name implies it is based on commons-httpclient-3.0-rc3. In order to acquire the maximum flexibility, this sender has implemented POST interface and GET interface. GET interface is provided to help axis2 support REST.
Chunking support and KeepAlive support is also integrated via the facilities provided by commons-httpclient along with HTTP 1.1 support.
<transportSender/> element is used to define transport senders in the axis2.xml as follows:
<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>
Above code snippet shows the complete configuration of the transport sender. <parameter/> element introduces the additional parameters that should be compliant with the sender. HTTP PROTOCOL version sets as HTTP/1.0 or HTTP/1.1. Default version is HTTP/1.1. It should be noted that chunking support is available only for HTTP/1.1. Thus, the user should be careful in setting the "chunked" property and use it only with version 1.1. KeepAlive property is default in version 1.1.
These are the only parameters that are available from deployment. Other parameters such as character encoding style (UTF-8, UTF-16 etc) etc, are provided via MessageContext.
<transportSender name="https" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
<parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
<parameter name="Transfer-Encoding">chunked</parameter>
</transportSender>
Please note that https works only when the server does not expect to authenticate the clients and where the server has the clients' public keys in its trust store.
There are two timeout exists in transport level. They are called, Socket timeout and Connection timeout. This can be configured in deployment time or in run time. In deployment time, user has to add the following lines in axis2.xml.
For Socket timeout:
<parameter name="SO_TIMEOUT" locked="false">some_int_value</parameter>
For Connection timeout:
<parameter name="CONNECTION_TIMEOUT" locked="false">some_int_value</parameter>
... Options options = new Options(); options.setProperty(HTTPConstants.SO_TIMEOUT,new Integer(some_int_value)); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT,new Integer(some_int_value)); ...
The default HTTP version is 1.1. There are two methods in which user can change HTTP version to 1.0
<parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter>
... options.setProperty(org.apache.axis2.context.MessageContextConstants.HTTP_PROTOCOL_VERSION,org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10); ...
HttpClient support "Basic, Digest and NTLM" authentication schemes. These are used to authenticate with http servers and proxies.
Axis2 uses deployment time and runtime mechanisms to authenticate proxies. In deployment time, user has to change the Axis2.xml as follows. This authentication will be available in http and https.
<transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> <parameter name="PROXY" proxy_host="proxy_host_name" proxy_port="proxy_host_port" locked="true>userName:domain:passWord</parameter> </transportSender>
For a particular proxy, if authentication is not available fill "userName:domain:passWord"as "anonymous:anonymous:anonymous".
At runtime user can override the PROXY settings with an Object of HttpTransportProperties.ProxyProperties. On the stub initiate an object of prior and set it to the MessageContext's property bag via HttpConstants.PROXY. On the stub, it depicts as follows,
... Options options = new Options(); .... HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.new ProxyProperties(); proxyProperties.setProxyHostName(....); proxyProperties.setProxyPort(...); ... options.setProperty(HttpConstants.PROXY, proxyProperties); ....
The above code would eventually override the deployment proxy configuration settings.
NTLM is the most complex of the authentication protocols supported by HttpClient. It requires an instance of NTCredentials be available for the domain name of the server or the default credentials. Note that since NTLM does not use the notion of realms HttpClient uses the domain name of the server as the name of the realm. Also note that the username provided to the NTCredentials should not be prefixed with the domain - ie: "axis2" is correct whereas "DOMAIN\axis2" is not correct.
There are some significant differences in the way that NTLM works compared with basic and digest authentication. These differences are generally handled by HttpClient, however having an understanding of these differences can help avoid problems when using NTLM authentication.