I\'ve trouble setting jax-ws timeout. My code is:
@WebServiceClient(name = \"VoipDBJDBCService\", targetNamespace = \"http://db.server.voipmeter.jextreme.eu/
You can cast your VoipDB
object to BindingProvider
. So in the example in the link you've given just replace proxy
by db
and you're good to go.
With Metro/Glassfish...
//1 minute for connection
((BindingProvider) wsPort).getRequestContext().put("com.sun.xml.ws.connect.timeout", 1 * 60 * 1000);
//3 minutos for request
((BindingProvider) wsPort).getRequestContext().put("com.sun.xml.ws.request.timeout", 3 * 60 * 1000);
Here is one example
public void testConfigureTimeout() throws Exception
{
//Set timeout until a connection is established
((BindingProvider)port).getRequestContext()
.put("javax.xml.ws.client.connectionTimeout", "6000");
//Set timeout until the response is received
((BindingProvider) port).getRequestContext()
.put("javax.xml.ws.client.receiveTimeout", "1000");
port.echo("testTimeout");
}
If you are using a Sun JRE, you can set the following system properties for default network connect and read timeouts (in milliseconds). I haven't tried these with the JAX-WS client, but they ought work there as well:
sun.net.client.defaultConnectTimeout
sun.net.client.defaultReadTimeout
Addition: I missed your last part of the question where you said that you are doing this in an applet. If the applet is running with default permissions, you are probably not allowed to set the system properties.
ProxyWs proxy = (ProxyWs) factory.create();
Client client = ClientProxy.getClient(proxy);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(0);
httpClientPolicy.setReceiveTimeout(0);
http.setClient(httpClientPolicy);
This worked for me.