title: Java SOAP/JAX-WS: How to set timeouts?
body: <p>I am calling a webservice with Java. It is working well but I'd like to set a connection timeout too. </p>
  
  <p>My code:</p>
  
  <pre><code>URL urlwsdl = new URL ("file://" + wsdl);
  QName qn = new QName("http://myserver/myservice", "MyService");
  port = new TimeSeriesService_Service (urlwsdl, qn).getMyServicePort (); 
  
  BindingProvider prov = (BindingProvider) port;
  prov.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://server1/myservice");
  prov.getRequestContext ().put (BindingProvider.USERNAME_PROPERTY, "max");
  prov.getRequestContext ().put (BindingProvider.PASSWORD_PROPERTY, "secret");
  
  QueryRequest1 req = new QueryRequest1 ();
  QueryResponse1 res = port.queryRequest1 (req);  // *** TIMEOUT for ~2 minutes
  </code></pre>
  
  <p>I found some posts on the internet. They use the context of the binding provider as I do for http-auth. </p>
  
  <p>e.g. </p>
  
  <pre><code>prov.getRequestContext ().put ("com.sun.xml.ws.request.timeout", 1000000);
  </code></pre>
  
  <p>But they use objects I do not have in my namespace.</p>
  
  <p>e.g.</p>
  
  <pre><code>sun.net.client.defaultConnectTimeout
  com.sun.xml.ws.connect.timeout
  com.sun.xml.ws.request.timeout
  </code></pre>
  
  <p>I have sun.net but not .client.
  I have com.sun.xml but not .ws.</p>
  
  <p>I have a simple java jdk (1.7, Debian 8.3, 64bit) and can compile and run my webservice, the webclient and also wsimport. No netbeans and no jboss installed.</p>
  
  <p>Any ideas how I can set a timeout?
  Thanks for help!
  Chris</p>