为Axis SOAP Web服务设置超时时间

8

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));

我该如何为连接建立和已打开的连接设置超时时间?(类似于org.apache.commons.net.SocketClientsetTimeout()setSoTimeout())?

我找到了一个提示,建议按照以下方式设置超时时间:

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

但是显式转换看起来更像是一种黑客行为,而不是官方API使用方式。
在源代码中搜索,我发现了对DefaultCommonsHTTPClientProperties.CONNECTION_DEFAULT_SO_TIMEOUT_KEY的引用,但我不知道我是否使用了Commons HTTP Client,也不知道如何应用此选项。
1个回答

8

我曾经使用过axis 1.4和soap,为了使用你的示例设置存根超时时间,我需要这样做:

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

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

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

2
以上解决方案不起作用。使用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/ - Santosh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接