Question

I connect to web service like this:

CalculatorService service = new CalculatorService();
Calculator client = service.getCalculatorPort();
((BindingProvider) client).getRequestContext().put(BindingProviderProperties.REQUEST_TIMEOUT, 5000);
((BindingProvider) client).getRequestContext().put(BindingProviderProperties.CONNECT_TIMEOUT, 5000);

Do I need to instantiate new JAX-WS client and set REQUEST_TIMEOUT, CONNECT_TIMEOUT if any exception occurs or I can reuse the same objects?

Was it helpful?

Solution

No, you don't need to instantiate new clients/ports. They can be reused in case of exceptions, but notice that they are not required to be threadsafe by the spec. So you should use multiple ports if you call them concurrently (although some implementations claim to have some degree of threadsafety, especially if you don't modify the request context, but this is implementation dependent).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top