我的基于Axis的客户端程序尝试连接到when服务,当服务器关闭时,我不想等待太长时间。我想最多等待3秒,所以我需要设置一个超时。
在调用类-Axis的JAXRPC动态调用上有CONNECTION_TIMEOUT_PROPERTY属性。我不知道怎么用它。我在网上搜索了很多,但我不知道该怎么做。我不能让连接超时起作用。
发布于 2011-10-01 21:56:36
我在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>发布于 2012-09-28 11:14:15
我在这里找到了通过存根设置超时的方法,它可能会对你有所帮助。
在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
发布于 2021-03-13 00:35:11
我发现这样做效果很好:
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://stackoverflow.com/questions/7397261
复制相似问题