Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I set the timeout for a JAX-WS webservice client?
    text
    copied!<p>I've used JAXWS-RI 2.1 to create an interface for my web service, based on a WSDL. I can interact with the web service no problems, but haven't been able to specify a timeout for sending requests to the web service. If for some reason it does not respond the client just seems to spin it's wheels forever.</p> <p>Hunting around has revealed that I should probably be trying to do something like this:</p> <pre><code>((BindingProvider)myInterface).getRequestContext().put("com.sun.xml.ws.request.timeout", 10000); ((BindingProvider)myInterface).getRequestContext().put("com.sun.xml.ws.connect.timeout", 10000); </code></pre> <p>I also discovered that, depending on which version of JAXWS-RI you have, you may need to set these properties instead:</p> <pre><code>((BindingProvider)myInterface).getRequestContext().put("com.sun.xml.internal.ws.request.timeout", 10000); ((BindingProvider)myInterface).getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", 10000); </code></pre> <p>The problem I have is that, regardless of which of the above is correct, I don't know <em>where</em> I can do this. All I've got is a <a href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/Service.html" rel="noreferrer"><code>Service</code></a> subclass that implements the auto-generated interface to the webservice and at the point that this is getting instanciated, if the WSDL is non-responsive then it's already too late to set the properties:</p> <pre><code>MyWebServiceSoap soap; MyWebService service = new MyWebService("http://www.google.com"); soap = service.getMyWebServiceSoap(); soap.sendRequestToMyWebService(); </code></pre> <p>Can anyone point me in the right direction?!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload