samaxes

samaxes logo

Ramblings about Open Source, Java and other Web technologies by Samuel Santos

Axis 1.4 Read timed out and HTTP 1.1

For those getting a SocketTimeoutException when calling an Axis 1.4 Web Service.
This may be a solution for your problem.

If your log show an error similar to this:

12:38:51,693 ERROR [TerminalSessionHelper] ; nested exception is: 
	java.net.SocketTimeoutException: Read timed out
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.net.SocketTimeoutException: Read timed out
 faultActor: 
 faultNode: 
 faultDetail: 
	{http://xml.apache.org/axis/}stackTrace:java.net.SocketTimeoutException: Read timed out
...

And your call looks like this:

TerminalSessionService terminalSessionService = new TerminalSessionServiceLocator();
 
TerminalSession_PortType terminalSession_PortType = terminalSessionService.getTerminalSession();
 
((TerminalSessionSOAPBindingStub) terminalSession_PortType).setTimeout(15000);

Try to use CommonsHTTPSender as the Transport Sender of the Axis client:

BasicClientConfig basicClientConfig = new BasicClientConfig();
SimpleChain simpleChain = new SimpleChain();
 
simpleChain.addHandler(new CommonsHTTPSender());
basicClientConfig.deployTransport("http", simpleChain);
 
TerminalSessionService terminalSessionService = new TerminalSessionServiceLocator(basicClientConfig);
 
TerminalSession_PortType terminalSession_PortType = terminalSessionService.getTerminalSession();
 
((TerminalSessionSOAPBindingStub) terminalSession_PortType).setTimeout(15000);

This also has the advantage to use HTTP 1.1 instead of HTTP 1.0.
Note: You will need to add the common-httpclient.jar and common.codec.jar to the jar directory for this to work.

Still want to use HTTP 1.0? No problem, just add the following line of code:

((TerminalSessionSOAPBindingStub) terminalSession_PortType)._setProperty(
        MessageContext.HTTP_TRANSPORT_VERSION, HTTPConstants.HEADER_PROTOCOL_V10);

Hope this can save your time. Axis can be really painful…

Bookmark and Share

Related Posts

One Response

  1. Stuart says:

    Great tip thanks! We experienced this issue on some PCs but not others, and couldn’t determine the different between the environments.

    After switching to ComonsHTTPSender it works fine on all machines.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Sponsors