How do I set a timeout when using WSDL2Java stubs? 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 The default timeout in Axis 1.1 and later is 60 seconds. Axis 1.0 did not have a default timeout (i.e. it defaulted to 0). This timeout value is set on the HTTP socket and is not a connection timeout, which requires implementation we do not have as of Axis 1.1.
For Socket timeout:<parameter name="SO_TIMEOUT" locked="false">some_int_value</parameter>For Connection timeout: <parameter name="CONNECTION_TIMEOUT" locked="false">some_int_value</parameter>At runtime it is set as follows in the Stub. ... Options options = new Options(); options.setProperty(HTTPConstants.SO_TIMEOUT,new Integer(timeOutInMilliSeconds)); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT,new Integer(timeOutInMilliSeconds));// oroptions.setTimeOutInMilliSeconds(timeOutInMilliSeconds); ... 我采用了配置文件的做法,不过错误是同样的,而且每次都是运行大概两分钟的时间出错,我也不知道会不会是其他的原因.
FooService binding = loc.getFooService();
org.apache.axis.client.Stub s = (Stub) binding;
s.setTimeout(1000); // 1 second, in miliseconds
The default timeout in Axis 1.1 and later is 60 seconds. Axis 1.0 did not have a default timeout (i.e. it defaulted to 0). This timeout value is set on the HTTP socket and is not a connection timeout, which requires implementation we do not have as of Axis 1.1.
Options options = new Options();
options.setProperty(HTTPConstants.SO_TIMEOUT,new Integer(timeOutInMilliSeconds));
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT,new Integer(timeOutInMilliSeconds));// oroptions.setTimeOutInMilliSeconds(timeOutInMilliSeconds);
...
我采用了配置文件的做法,不过错误是同样的,而且每次都是运行大概两分钟的时间出错,我也不知道会不会是其他的原因.