Troubleshooting
Problem
Sometimes it is necessary to control how long a Web Service client waits for a response after sending a request. This document discusses Java API for XML-based Remote Procedure Call (JAX-RPC) clients only and not SOAP with Attachments API for Java (SAAJ) or Dynamic Invocation Interface (DII) clients.
Symptom
In IBM WebSphere Application Server Version the following error occurs if a JAX-RPC Web service client times out:
java.net.SocketTimeoutException: Socket operation timed out before it could be completed
Resolving The Problem
For a JSR 109-compliant JAX-RPC client, there are Web service client deployment descriptors that are packaged with the application. Specifically, the ibm-webservicesclient-bnd.xmi deployment descriptor is used to control the client timeout. This deployment descriptor has a syncTimeout property. The default for this timeout value is 5 seconds. To set the syncTimeout property, see the following directions in the product documentation for WebSphere Application Server:
Configuring the JAX-RPC web services client bindings in the ibm-webservicesclient-bnd.xmi deployment descriptor
Some JAX-RPC clients do not have this deployment descriptor. These clients are not JSR 109-compliant. You can alternatively set the timeout value on the stub using the setTimeout method. Here is sample code to set the timeout value on a stub:
package mypackage;
import com.ibm.ws.webservices.engine.client.Stub;
public class J2SEClient {
public static void main(String[] args) {
try
{
HelloWorldServiceLocator hwsl = new HelloWorldServiceLocator();
HelloWorld hw = hwsl.getHelloWorld();
((Stub) hw).setTimeout(60000);
hw.sayHello();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
In the previous sample code, the parameter for the setTimeout method is the number of milliseconds the client should wait for a response from the provider.
To ensure that this timeout is set properly in WebSphere Application Server V6.0, the following trace specification can be used:
com.ibm.ws.webservices.engine.*=all
In the trace, the HttpOutboundChannelConnection class will output the following:
WSWS3494I: syncTimeout value is 420 seconds to wait for response to the current SOAP over HTTP request.
Notes:
- The operating system timeouts might cause the connection to time out before the syncTimeout length.
- Setting the time-out to 0 will prevent the readTimeout from happening (for example, the client will not time out)
- If the timeout is less than 1000 milliseconds, WebSphere JAX-RPC Web Services engine we will treat it as an invalid timeout setting and try to convert its to timeout*1000.
- WebSphere JAX-RPC Web Services engine does not support to set the timeout less than 1000 milliseconds.
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21224016