2009-04-30 70 views
0

我有下面的代碼,我正嘗試通過使用Apache CXF通過HTTPS訪問web服務。但是,只要我的信息消失,我的代碼超時之前我什麼也收不回來。有人可以給我的代碼一次,讓我知道如果我做錯了什麼。我試圖通過SoapUI訪問服務,這很好,所以它必須是我的CXF代碼中的東西,但我只是不知道該怎麼做!CXF&SSL:超時問題

感謝所有幫助

DepositImplService ss = new DepositImplService(WSDL_LOCATION, 
    SERVICE_NAME); 
PortType port = ss.getPortTypePort(); 

Client client = ClientProxy.getClient(port); 

HTTPConduit conduit = (HTTPConduit) client.getConduit(); 
HTTPClientPolicy httpClientPolicy = conduit.getClient(); 
httpClientPolicy.setConnectionTimeout(30000); 
httpClientPolicy.setReceiveTimeout(30000); 
conduit.setClient(httpClientPolicy); 

AuthorizationPolicy authPolicy = new AuthorizationPolicy(); 
authPolicy.setUserName("foo"); 
authPolicy.setPassword("bar"); 
conduit.setAuthorization(authPolicy); 

TLSClientParameters parameters = new TLSClientParameters(); 
parameters.setSecureSocketProtocol("SSL"); 
conduit.setTlsClientParameters(parameters); 

client.getInInterceptors().add(new LoggingInInterceptor()); 
client.getOutInterceptors().add(new LoggingOutInterceptor()); 

UploadRequestT doc = new UploadRequestT(); 
BufferedReader reader = new BufferedReader(new FileReader(new File(
    "C:\\rawmessage.txt"))); 
String documentStr = ""; 
String currLine = ""; 
while ((currLine = reader.readLine()) != null) { 
    documentStr += currLine; 
} 

doc.setDoc(documentStr); 
doc.setOwner("43"); 
port.upload(doc); 

回答

0

什麼是了SoapUI的響應時間?

你是否通過監視器運行它,看它是否發送到正確的地方?

我CXF代碼如下所示:

 PService phsService = new PService(url, SERVICE_NAME); 
     P p = phsService.getPHSPort(); 
     LOG.info("Calling Web Service : getHs"); 

     StringArray ar = p.getHs(); 

     for (String hn: ar.getItem()) { 
     LOG.info("Calling : getHName : " + hn); 
     Dto nDto = p. getHName (hn); 

     // process the result 

     } 

該服務大約需要90secs返回,並運行良好

+0

響應時間幾乎是瞬間。監視工具的好主意 - 我會看看是什麼告訴我的。 – 2009-04-30 10:59:35