我有以下代码,我尝试使用Apache CXF通过HTTPS访问Web服务。但是每当我的消息消失时,在代码超时之前我什么也得不到。有人可以给我的代码一次,让我知道我做错了什么。我试图通过SoapUI访问该服务,这很好,所以它必须是我的CXF代码中的东西,但我只是不知道是什么!

感谢您的帮助

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);
有帮助吗?

解决方案

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   

      }

此服务大约需要90秒才能返回并运行正常

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top