How to configure timeouts at client side for Apache CXF web services?

I’m extending the example at to show how to set connection/receive timeout duration for a CXF client.

. . .

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("client-beans.xml");
CalculationServerIfc client = (CalculationServerIfc) context.getBean("client");

ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
Client proxy = ClientProxy.getClient(client);

HTTPConduit conduit = (HTTPConduit) proxy.getConduit();

// HTTPClientPolicy - Properties used to configure a client-side HTTP port
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); // Line #1

httpClientPolicy.setConnectionTimeout(30000); // Line #2
httpClientPolicy.setReceiveTimeout(60000); // Line #3


System.out.println("Adding 5 and 4: " + client.add(5,4));

. .

If you’d like to wait indefinitely for connecting to server, or receiving a response, either do not add marked lines in code, or set the timeouts to zero.


One comment

  1. […] How to configure timeouts at client side for Apache CXF web services? ( Share this:EmailPrintDiggStumbleUponFacebookTwitterRedditLinkedInLike this:LikeBe the first to like this post. […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: