Axis 1.4 Read timed out and HTTP 1.1

April 6th, 2009 by Samuel Santos Leave a reply »

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…

Related Posts

Advertisement

4 comments

  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.

  2. Bajaj says:

    Very useful info. Thanks much.

  3. Scott says:

    Great explanation and post for switching to the CommonsHTTPSender. I too, like Stuart, had some issues but after making this switch to my Axis client my machine was working fine. The screenshot instructions were a great tool for this switch.

  4. Simon says:

    super tip! will try switching the CommonsHTTPSender lie this and report back as soon as!

Leave a Reply