java - Axis2 ServiceClient 选项忽略超时

标签 java rest soap timeout axis2

我在以下版本中使用 Axis2:

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: The host did not accept the connection within timeout of 60000 ms

而且它确实也需要 60 秒。所以错误消息不仅仅是错误的,似乎超时选项只是被忽略了,它总是使用默认值。

有人遇到过类似的问题吗?

谢谢
塞巴斯蒂安

最佳答案

我能够解决这个问题(尽管它看起来有点重复)

int timeOutInMilliSeconds = 2000;
options.setTimeOutInMilliSeconds(timeOutInMilliSeconds);
options.setProperty(HTTPConstants.SO_TIMEOUT, timeOutInMilliSeconds);
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, timeOutInMilliSeconds);

塞巴斯蒂安

关于java - Axis2 ServiceClient 选项忽略超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13522686/

相关文章:

java - 如何使用 Reactor 框架 2.x 执行多线程 map/reduce?

java - 如何以编程方式创建 Spring 计划作业?

Java - 将套接字与代理一起使用

java - 如何在 spring 项目中正确注入(inject) @Autowired 依赖而不使用 getBean?是否可以?

java - 获取特定迭代下的所有任务(符合条件)?

c# - 从 ASP.NET Core Web 方法提供 SOAP

django - 枚举 Django Rest Framework 序列化器中的模型选择

java - 异步JAX-RS

javascript - 从 Node.js 多次调用 Web 服务

php - 如何在 php 中使用 soap 调用 Web 服务