Setting jax-ws client timeout

前端 未结 5 427
抹茶落季
抹茶落季 2020-12-29 10:24

I\'ve trouble setting jax-ws timeout. My code is:

@WebServiceClient(name = \"VoipDBJDBCService\", targetNamespace = \"http://db.server.voipmeter.jextreme.eu/         


        
相关标签:
5条回答
  • 2020-12-29 10:32

    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.

    0 讨论(0)
  • 2020-12-29 10:38

    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); 
    
    0 讨论(0)
  • 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");
    }
    
    0 讨论(0)
  • 2020-12-29 10:46

    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.

    0 讨论(0)
  • 2020-12-29 10:50
    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.

    0 讨论(0)
提交回复
热议问题