JPragma Blog

Pragmatic Developers, Elegant Software

Setting timeout on Axis WebService calls

with 2 comments

In several projects we participated, there was a need to call external Web Services using Java classes generated by wsdl2java Axis tool (or wsdl2java goal of axistools-maven-plugin).

Sometimes these external systems that exposed Web Services experienced high load, slow database and other factors, which caused our calls to them to take outrageously long time before the response have been received.
So, we had to introduce timeouts and handle such calls as errors.

Looking into Axis documentation we found that there is a wsdl2java “timeout” parameter available in both command line tool and via maven plugin. However setting this parameter had no effect, our calls were still hanging indefinitely. It’s not even clear from the documentation if this timeout is applied to webservice call or to execution of wsdl2java itself.

Anyways to have a timeout on webservice call the one must be set on instance of org.apache.axis.client.Call prior to calling invoke(). But creation of Call instance and setting of all its properties is done from Axis generated code and all your changes there will be overwritten on next wsdl2java run.

The solution is to set timeout property on the class that extends org.apache.axis.client.Stub, it’s Axis generated class and would be called something like MyWebServicePort_PortType. If timeout on Call is not set it uses the value from Stub.
This solution is also much more flexible, because now you can set different timeouts on various calls depending on your business logic.

Written by isaaclevin

December 17, 2010 at 11:02 am

Posted in Java

Tagged with , , ,

2 Responses

Subscribe to comments with RSS.

  1. Thanks for the tip. That helped me a lot


    September 8, 2012 at 1:06 pm

  2. explaination is quite good but rather even an example would also be greatly appreciated.

    Natraj Chigarambatla

    June 12, 2013 at 5:06 am

Leave a Reply to Juan Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: