2012-04-19 103 views
1

我已經使用WSDLToJava生成客戶端存根。之後,我創建了這裏提到的客戶http://cxf.apache.org/docs/developing-a-consumer服務超時問題

this.testService = new TestService(wsdlURL, SERVICE_NAME); //line #1 
    this.port = testService.getTestPort();   //line #2 
    Client client = ClientProxy.getClient(port);  //line #3 
    client.getInInterceptors().add(new LoggingInInterceptor()); 
    client.getOutInterceptors().add(new LoggingOutInterceptor()); 
    HTTPConduit conduit = (HTTPConduit)client.getConduit(); 
    // setting timeouts for connection 
    String timeOutSecond = CoreProperty.getProp(CORE_SERVICE_TIME_OUT_MILLISECONDS); 
    int timeout =0; 
    try{ 
     if(Utils.isNotNullOrBlank(timeOutSecond)) 
      timeout = Integer.parseInt(timeOutSecond.trim()); 
     else 
      timeout = Constants.DEFAULT_SERVICE_TIME_OUT_MILLISECONDS; 
    }catch (NumberFormatException e) { 
     timeout = Constants.DEFAULT_SERVICE_TIME_OUT_MILLISECONDS; 
    } 
    conduit.getClient().setReceiveTimeout(timeout); 

的問題是,線#1正在採取近5分鐘,如果服務器關閉拋出錯誤 - 在wsdlURL規定。

我想設置一個超過30秒的時間來建立客戶端連接。

如果服務已啓動,所有工作正常,並且receivetimeout設置正常。我如何設置建立連接的超時時間。 如果服務器關閉,程序正在#1線等待,它等待着超過4分鐘,我想避免這種情況。

謝謝你的時間。請幫忙

+0

超時通過'conduit.getClient()setConnectionTimeout(...)',設置連接是你在找什麼? – 2012-04-21 09:58:42

回答