我使用Axis2的版本:的Axis2 ServiceClient选项忽略超时
Implementation-Version: 1.7.0-SNAPSHOT
Implementation-Vendor-Id: org.apache.axis2
Implementation-Vendor: The Apache Software Foundation
Jenkins-Build-Number: 1847
我想设置的ServiceClient到2000毫秒的超时时间,这是我们的代码:
Options options = new Options();
options.setTo(new EndpointReference(getUserServiceEndPoint()));
options.setProperty(Constants.Configuration.ENABLE_REST,
Constants.VALUE_TRUE);
// setting timeout to 2 second should be sufficient, if the server is
// not available within the 3 second interval you got a problem anyway
options.setTimeOutInMilliSeconds(2000);
ServiceClient sender = new ServiceClient();
sender.engageModule(new QName(Constants.MODULE_ADDRESSING)
.getLocalPart());
sender.setOptions(options);
OMElement getSessionResult = sender
.sendReceive(getPayloadMethodGetSession());
不过我还是请参阅日志:
org.apache.axis2.AxisFault:主机在超时时间内不接受连接 o f 60000 ms
而且它确实也需要60秒。所以错误信息不仅仅是错误的,它看起来像超时选项被忽略,它总是使用默认的选项。
任何人都有类似的问题?
谢谢
塞巴斯蒂安
它看起来复制,但两个超时有一个重要的区别。 SO_TIMEOUT是尝试建立与服务器的连接时的超时时间。 CONNECTION_TIMEOUT是套接字在请求发送后等待接收响应的时间。 –
但什么是options.setTimeOutInMilliSeconds(timeOutInMilliSeconds);对吗?它似乎根本没有效果。 –
我希望我能告诉你。 Options类中的javadoc没有提供很多信息。我会想通过一种方法来设置这两个值。我的google-fu似乎也很难得到答案。 –