Вопрос

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?

Это было полезно?

Решение

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).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top