我想使用 Java 中的 Web 服务,并且我正在使用 JAX.WS。一切工作正常,直到我尝试通过 SSL (https) 使用 Web 服务。我已使用 keytool 将站点的证书添加到 keystore 中。仍然没有成功。以前有人做过吗?该网络服务来自第三方支付网关,例如 paypal-payflo 等......因此,其证书来自 Verisign 的常规网络服务。任何提示都会有所帮助。它是一个带有 wsdl 的 SOAP Web 服务。
错误跟踪:
Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: xxxxx.xxxxxx.xxx/creditcardWS/CreditCardService/v1?wsdl. It failed with: Got Connection refused: connect while opening stream from xxxxxx.xxxxxx.xxx/creditcardWS/CreditCardService/v1?wsdl. at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:173) at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:155) at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:120) at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:260) at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:223) at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:171) at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:96)
最佳答案
将您自己的 keystore 设置为 javax.net.ssl.trustStore 有帮助吗?
String keystorePath = "local.keystore";
System.setProperty("javax.net.ssl.trustStore", keystorePath);
请务必检查是否可以从该路径读取(当前示例假设 local.keystore
位于类路径中。
关于java - 在 Java 中通过 SSL 使用 WebService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12728350/