I have an user requirement to set timeout per request such that the user can specify the timeout for the web service.
Client client = ClientProxy.getClient(port); client.getRequestContext().put("thread.local.request.context", "true"); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setAllowChunking(false); httpClientPolicy.setAccept("text/xml"); httpClientPolicy.setAcceptEncoding("gzip,deflate,sdch"); httpClientPolicy.setCacheControl("No-Cache"); httpClientPolicy.setContentType("text/xml"); httpClientPolicy.setConnectionTimeout(2000); httpClientPolicy.setReceiveTimeout(receiveTimeout); HTTPConduit http = (HTTPConduit) client.getConduit(); http.setClient(httpClientPolicy); receiveTimeout above is a parameter. I found out that if the port is a static variable (shared by all threads), then after the first user set receiveTimeout, the 2nd user will be affected by this setting. What I want to achieve is that if the user does not set the receiveTimeout, it will be using CXF default which is 60s and it will be affected by other threads.