EverSpring007 2015-06-03 09:16 采纳率: 0%
浏览 2580
已结题

通过myeclipse生成的webservice代码,访问超时

目前遇到一个问题,通过Myeclipse生成的webservice客户端代码(好像是jax-ws),如果访问的url不存在,就一直卡着,很久才报超时异常,有没有什么办法可以设置超时时间

 public ServiceCD() {
        super(
                CD_WSDL_LOCATION,
                new QName(
                        "http://xx.com/basic/atomic/operation.CD",
                        "CD"));
    }

上面是生成的代码。以下是我访问的代码:访问的时候就一直卡在这里。
网上有很多方法都不起作用。我使用过的方法有:

ServiceCD service = new ServiceCD(url, new QName(
                    url,
                    "CD"));
1、Map<String, Object> ctxt = ((BindingProvider)port).getRequestContext();
            ctxt.put(BindingProviderProperties.CONNECT_TIMEOUT, config.getConntimeout());
            ctxt.put(BindingProviderProperties.REQUEST_TIMEOUT, config.getTimeout());

            2、URL mbr_service_url = new URL(null,GlobalVars.MemberService_WSDL, new URLStreamHandler() {

            @Override
            protected URLConnection openConnection(URL url) throws IOException {
                URL clone_url = new URL(url.toString());
                HttpURLConnection clone_urlconnection = (HttpURLConnection) clone_url.openConnection();
                // TimeOut settings
                clone_urlconnection.setConnectTimeout(10000);
                clone_urlconnection.setReadTimeout(10000);
                return (clone_urlconnection);
            }
        });
        ServiceCD service = new ServiceCD(mbr_service_url);
        ```     
                这些都不起作用。
                求助!!!!



  • 写回答

1条回答

  • leffleft 2015-06-04 05:59
    关注
    HttpURLConnection conn = null;
        OutputStream out = null;
        String rsp = null;
        try {
            try {
                conn = getConnection(new URL(url), METHOD_POST, ctype, headerMap);
                conn.setConnectTimeout(connectTimeout);
                conn.setReadTimeout(readTimeout);
    
                你要对connection设置超时时间,
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog