0

我有以下代码,我正在尝试使用 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);
4

1 回答 1

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   

      }

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

于 2009-04-30T10:47:39.767 回答