Setting the timeout value for a JAX-RPC Web Service client

Technote (troubleshooting)


Problem(Abstract)

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 Information Center 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)

Cross reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

WebSphere Application Server
Web Services (for example: SOAP or UDDI or WSGW or WSIF)

Software version:

6.0, 6.1, 7.0, 8.0, 8.5, 8.5.5

Operating system(s):

AIX, HP-UX, Linux, Solaris, Windows

Software edition:

Base, Network Deployment

Reference #:

1224016

Modified date:

2006-10-13

Translate my page

Machine Translation

Content navigation