Setting Timeout for Axis SOAP Webservice

24,039

I used to use axis 1.4 and soap as well, to set timeout for stub with your example, I would do as:

FooServiceLocator fooLocator = new FooServiceLocator();
fooLocator.getEngine().setOption("sendMultiRefs", false);
Foo foo = fooLocator.getFooService(new URL(soapServiceUrl));

FooStub binding = (FooStub) foo;
binding.setTimeout(soapTimeoutSecs * 1000);

Your FooStub is extended to org.apache.axis.client.Stub and if you generated the classes via wsdl2java you would got them already.

Share:
24,039
lathspell42
Author by

lathspell42

Updated on March 13, 2021

Comments

  • lathspell42
    lathspell42 about 3 years

    I'm using an Axis 1.4 webservice like this:

    FooServiceLocator fooLocator = new FooServiceLocator();
    fooLocator.getEngine().setOption("sendMultiRefs", false);
    Foo foo = fooLocator.getFooService(new URL(soapServiceUrl));
    

    How can I set a timeout for the connection establishment and for the opened connection? (Similar to org.apache.commons.net.SocketClient setTimeout() and setSoTimeout())?

    I found a hint that suggested setting a timeout like this:

    ((Stub) sPcspService).setTimeout(soapTimeoutSecs * 1000);
    

    but the explicit cast looks more like a hack than on official API usage.

    Grepping the source code I found references to

    DefaultCommonsHTTPClientProperties.CONNECTION_DEFAULT_SO_TIMEOUT_KEY

    but neither do I know if I use the Commons HTTP Client or another, nor how to apply this option.

  • Santosh
    Santosh almost 8 years
    Above solution is not working. Using Axis 1.4 & Java 1.7. In-fact, not a single approach is working for Axis read time out.. surprise ! Tried all options mentioned in below link - wiki.apache.org/ws/FrontPage/Axis/AxisCommonsHTTP --/-- coderanch.com/t/544075/Web-Services/java/… --/-- samaxes.com/2009/04/axis-14-read-timed-out-and-http-11