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.
Hunting around has revealed that I should probably be trying to do something like this:
((BindingProvider)myInterface).getRequestContext().put("com.sun.xml.ws.request.timeout", 10000);
((BindingProvider)myInterface).getRequestContext().put("com.sun.xml.ws.connect.timeout", 10000);
I also discovered that, depending on which version of JAXWS-RI you have, you may need to set these properties instead:
((BindingProvider)myInterface).getRequestContext().put("com.sun.xml.internal.ws.request.timeout", 10000);
((BindingProvider)myInterface).getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", 10000);
The problem I have is that, regardless of which of the above is correct, I don't know where I can do this. All I've got is a Service
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:
MyWebServiceSoap soap;
MyWebService service = new MyWebService("http://www.google.com");
soap = service.getMyWebServiceSoap();
soap.sendRequestToMyWebService();
Can anyone point me in the right direction?!
internal
one is legacy and probably the non-internal one as well. I think in the future, the one starting withjavax.xml.ws
will become the standard. A good way to find out which is right is to search for a class namedJAXWSPropertie
s in your project and the right property is in there. You can even import it from there so that if you change an implementation, you will get notified of the change instead of having the functionality break as it happened to me while switching to Jakarta for an upgrade from Java 8 upwards :-) – Carnify