Reputation: 376
My problem is that I call a remote web service that requires more than 60 seconds to respond and this causes a timeout exception. I do not want any timeout check: I just want the sender to wait until the web service ends. I tried to set:
HttpSession httpSession = getThreadLocalRequest().getSession();
httpSession.setMaxInactiveInterval(120000);
getThreadLocalRequest().setAttribute("session", httpSession);
to modify the web.xml session-timeout (even though I do not think that it is related with my problem) to create a custom HttpRequest. Timeout persists. Is there any way to shutdown this check?
Upvotes: 2
Views: 6910
Reputation: 376
Found the solution:
/* Connect to the service */
ClientProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
factoryBean.setServiceClass(MyService.class);
factoryBean.setAddress("service-url");
myService = (MyService) factoryBean.create();
/* Retrive HTTP client policy and set the receive timeout */
Client client = ClientProxy.getClient(myService);
HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = httpConduit.getClient();
httpClientPolicy.setReceiveTimeout(timeoutMilliseconds);
Upvotes: 1
Reputation: 5060
httpSession.setMaxInactiveInterval is not what you're after. You probably want to set connectTimeout and readTimeout on URLConnection. How to do that, depends on what tool you use to call the remote webservice.
Can you add some more details about the service, if it's a SOAP-service, REST-service etc, and what library you use to call the service?
Upvotes: 0