2009-04-30 62 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