设置jax-ws客户端超时 [英] Setting jax-ws client timeout

查看:187
本文介绍了设置jax-ws客户端超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在设置jax-ws超时方面遇到了麻烦。我的代码是:

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

@WebServiceClient(name = "VoipDBJDBCService", targetNamespace = "http://db.server.voipmeter.jextreme.eu/", wsdlLocation = "http://trace0.nyc.blinkmind.com:8080/voipdb?wsdl")
public class VoipDBJDBCService extends Service {
    public VoipDBJDBCService(URL wsdlLocation) {
        super(wsdlLocation, new QName("http://db.server.voipmeter.jextreme.eu/", "VoipDBJDBCService"));
    }

    @WebEndpoint(name = "VoipDBJDBCPort")
    public VoipDB getVoipDBJDBCPort() {
        return super.getPort(new QName("http://db.server.voipmeter.jextreme.eu/", "VoipDBJDBCPort"), VoipDB.class);
    }
}

用法:

VoipDB db = new VoipDBJDBCService(new URL(url)).getVoipDBJDBCPort();

我如何挂断超时?我在这里找到了解决方案: https://jax-ws.dev。 java.net/guide/HTTP_Timeouts.html 但我不知道我将把它挂钩。如何获取代理?当我调用getPort客户端尝试连接然后在服务器没有响应时永远挂起。

How do i Hook in timeouts ? I've found "solution" here: https://jax-ws.dev.java.net/guide/HTTP_Timeouts.html but I don't know where I shall hook it in. How to obtain proxy ? When I call getPort client tries to connect and then hangs forever if server is not responding.

更新:
此代码从applet init()方法中调用如果这有任何区别。

UPDATE: This code is invoked from within applets init() method if that makes any difference.

推荐答案

使用Metro / Glassfish ......

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); 

这篇关于设置jax-ws客户端超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆