0

In my web-service client (JAX-WS RI 2.2.9-b14002) I'm setting quite low connection and request timeouts, but for some methods I would like to override them in a way that default timeout doesn't change. Saying it in different words, I would like to set higher request-timeout when user invokes specific method, preserving the default timeout for all other methods.

Thanks in advance, bye

Gamby
  • 585
  • 1
  • 6
  • 22
  • Have a loook at this [snippet of code](https://gist.github.com/mageddo/b16c0ae1860458eee3e18c1e41830dc8) this allow you to set a global then a per request timeout – deFreitas Sep 10 '18 at 03:14

2 Answers2

0

You can do this by creating a ClientConfig first and providing it as an argument when creating the new client.

ClientConfig configuration = new ClientConfig();
configuration.property(ClientProperties.CONNECT_TIMEOUT, 1000);
configuration.property(ClientProperties.READ_TIMEOUT, 1000);
Client client = ClientBuilder.newClient(configuration);
RoshanKumar Mutha
  • 2,235
  • 1
  • 12
  • 13
  • Why should I recreate client before calling another method, it doesn't make sense. Thanks Ros but it isn't the answer I'm looking for :( – Gamby May 29 '17 at 10:22
0

You can do that by using request context I believe

requestContext.put(BindingProviderProperties.REQUEST_TIMEOUT, REQUEST_TIMEOUT);
requestContext.put(BindingProviderProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT);
  • Thanks but I don't ever asked that :) Furthermore BindingProviderProperties come from com.sun.xml.internal.ws.client. and the usage of internal packages produces compilation errors. – Gamby May 29 '17 at 14:14