为Axis SOAP Webservice设置超时

lat*_*l42 8 java axis soap timeout

我正在使用像这样的Axis 1.4 webservice:

FooServiceLocator fooLocator = new FooServiceLocator();
fooLocator.getEngine().setOption("sendMultiRefs", false);
Foo foo = fooLocator.getFooService(new URL(soapServiceUrl));
Run Code Online (Sandbox Code Playgroud)

如何为连接建立和打开的连接设置超时?(与org.apache.commons.net.SocketClient setTimeout()和相似setSoTimeout())?

我发现了一个提示,建议设置这样的超时:

((Stub) sPcspService).setTimeout(soapTimeoutSecs * 1000);
Run Code Online (Sandbox Code Playgroud)

但是显式演员看起来更像是黑客,而不是官方的API使用.

点击源代码我找到了引用

DefaultCommonsHTTPClientProperties.CONNECTION_DEFAULT_SO_TIMEOUT_KEY

但我不知道我是否使用了这个Commons HTTP Client或另一个,也不知道如何应用这个选项.

Osi*_*ify 8

我曾经使用轴1.4和肥皂,用你的例子设置存根的超时,我会这样做:

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

FooStub binding = (FooStub) foo;
binding.setTimeout(soapTimeoutSecs * 1000);
Run Code Online (Sandbox Code Playgroud)

您的FooStub扩展到org.apache.axis.client.Stub,如果您通过wsdl2java生成了类,那么您已经获得了它们.

  • 以上解决方案无效.使用Axis 1.4和Java 1.7.事实上,没有一种方法适用于Axis读取超时..惊喜!尝试了以下链接中提到的所有选项 - http://wiki.apache.org/ws/FrontPage/Axis/AxisCommonsHTTP - / - http://www.coderanch.com/t/544075/Web-Services/java/ set-timeout-Axis-client - / - https://samaxes.com/2009/04/axis-14-read-timed-out-and-http-11/ (2认同)