轴连接超时

发布于 12-04 12:40 字数 182 浏览 1 评论 0原文

我的基于 Axis 的客户端程序尝试连接到 Web 服务,当服务器关闭时我不想等待太多时间。我想最多等待 3 秒,所以我需要设置超时。

调用类 -Axis 的 JAXRPC 动态调用上有属性 CONNECTION_TIMEOUT_PROPERTY 。我不知道如何使用它。搜索了很多网络,但没有找到如何做到这一点。我无法让连接超时工作。

My Axis based client program tries to connect to a webservice, when the server is down I don't want to wait too much time . I want to wait max 3 seconds, So I need to set a timeout.

There is attribute CONNECTION_TIMEOUT_PROPERTY on the Call class -Axis' JAXRPC Dynamic Invocation . I don't know how to use it. serached alot the web and didn't find out how to do it.I cannot get connection timeouts to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

满身野味2024-12-11 12:40:30

我在 Axis 1.3 的客户端代理中使用这样的定义:

<bean id="serviceTarget" class="com.nxsec.log4ensics.dbmanager.ws.DMJaxRpcPortProxyFactoryBean">
  <property name="customPropertyMap"><map>
    <entry key="axis.connection.timeout">
      <value type="java.lang.Integer">3000</value>
    </entry>
  </map></property>
</bean>

I use such definition in client proxy for Axis 1.3:

<bean id="serviceTarget" class="com.nxsec.log4ensics.dbmanager.ws.DMJaxRpcPortProxyFactoryBean">
  <property name="customPropertyMap"><map>
    <entry key="axis.connection.timeout">
      <value type="java.lang.Integer">3000</value>
    </entry>
  </map></property>
</bean>
泛滥成性2024-12-11 12:40:30

我在这里找到了通过存根设置超时的方法,它可能对你有帮助。

org.apache.axis.client.Stub 类上有一个 setTimeout 方法,该类是所有发出的存根扩展的类。

以下是如何设置名为 Foo 的服务的超时:

FooServiceLocator loc = new FooServiceLocator();
FooService binding = loc.getFooService();
org.apache.axis.client.Stub s = (Stub) binding;
s.setTimeout(1000);  // 1 second, in miliseconds

请参阅:http://ws. apache.org/axis/faq.html#faq17

I found here the way to set timeout by stub, it might help you.

There is a setTimeout method on the org.apache.axis.client.Stub class, which is the class all emitted stubs extend.

Here is how to set the timeout given a service named Foo:

FooServiceLocator loc = new FooServiceLocator();
FooService binding = loc.getFooService();
org.apache.axis.client.Stub s = (Stub) binding;
s.setTimeout(1000);  // 1 second, in miliseconds

See: http://ws.apache.org/axis/faq.html#faq17

天生の放荡2024-12-11 12:40:30

我发现这个效果很好:

long soTimeout = 2 * 60 * 1000; // Two minutes
Stub stub = new TestStub();
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(soTimeout);
 
//or
 
int timeOutInMilliSeconds = 2 * 60 * 1000; // Two minutes
Stub stub = new TestStub();
stub._getServiceClient().getOptions().setProperty(
                 HTTPConstants.SO_TIMEOUT, timeOutInMilliSeconds);
stub._getServiceClient().getOptions().setProperty(
                 HTTPConstants.CONNECTION_TIMEOUT, new Integer(timeOutInMilliSeconds));

在这里找到:https://singztechmusings.wordpress.com/2011/05/07/how-to-configure-timeout-duration-at-client-side-for-axis2-web-services/

I found this to work well:

long soTimeout = 2 * 60 * 1000; // Two minutes
Stub stub = new TestStub();
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(soTimeout);
 
//or
 
int timeOutInMilliSeconds = 2 * 60 * 1000; // Two minutes
Stub stub = new TestStub();
stub._getServiceClient().getOptions().setProperty(
                 HTTPConstants.SO_TIMEOUT, timeOutInMilliSeconds);
stub._getServiceClient().getOptions().setProperty(
                 HTTPConstants.CONNECTION_TIMEOUT, new Integer(timeOutInMilliSeconds));

Found here: https://singztechmusings.wordpress.com/2011/05/07/how-to-configure-timeout-duration-at-client-side-for-axis2-web-services/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文