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…

Comments

comments powered by Disqus