java Axis2 ServiceClient 选项忽略超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13522686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Axis2 ServiceClient options ignore timeout
提问by seba.wagner
I am using Axis2 in version:
我在版本中使用 Axis2:
Implementation-Version: 1.7.0-SNAPSHOT
Implementation-Vendor-Id: org.apache.axis2
Implementation-Vendor: The Apache Software Foundation
Jenkins-Build-Number: 1847
I want to set the timeout of the ServiceClient to 2000 milliseconds, this is our code:
我想将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());
However I still see in the logs:
但是我仍然在日志中看到:
org.apache.axis2.AxisFault: The host did not accept the connection within timeout of 60000 ms
org.apache.axis2.AxisFault:主机在 60000 毫秒的超时时间内没有接受连接
And it really takes also 60 seconds. So the error message is not just wrong, it seems like the timeout option is just ignored and it always uses the default one.
它也确实需要 60 秒。所以错误信息不仅仅是错误的,似乎超时选项被忽略了,它总是使用默认选项。
Anybody had a similar issue ?
有人有类似的问题吗?
Thanks
Sebastian
由于
塞巴斯蒂安
回答by seba.wagner
I was able to resolve the issue (although it looks somehow duplicated to me)
我能够解决这个问题(虽然它看起来在某种程度上重复了我)
int timeOutInMilliSeconds = 2000;
options.setTimeOutInMilliSeconds(timeOutInMilliSeconds);
options.setProperty(HTTPConstants.SO_TIMEOUT, timeOutInMilliSeconds);
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, timeOutInMilliSeconds);
Sebastian
塞巴斯蒂安
回答by user2651178
Per API doc of Axis2 1.6.3, it is either the two properties or the timeOutInMillis like :
根据 Axis2 1.6.3 的 API 文档,它是两个属性或 timeOutInMillis,如:
Options options = new Options();
options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(timeOutInMilliSeconds));
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(timeOutInMilliSeconds));
OR
或者
options.setTimeOutInMilliSeconds(timeOutInMilliSeconds);
SOURCE:http://axis.apache.org/axis2/java/core/docs/http-transport.html
来源:http : //axis.apache.org/axis2/java/core/docs/http-transport.html