Clyde
Clyde

Reputation: 93

Consuming a WebService over SSL in Java

I want to consume a web service in Java and I am using JAX.WS. Everything is working fine until I try to consume a webservice over SSL (https). I have added the certificate of the site to keystore using keytool. Still no success. Anyone has done it before ? The webservice is from a third party payment gateway like paypal-payflo etc... so regular webservice whose certificate comes from Verisign. Any tip would help. It is a SOAP webservice with wsdl.

The error trace:

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(RuntimeWSDLPars‌​er.java:173) at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.ja‌​va:155) at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.ja‌​va:120) at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.jav‌​a:260) at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:2‌​23) at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:1‌​71) at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java‌​:96)

Upvotes: 0

Views: 2518

Answers (1)

ilvez
ilvez

Reputation: 1285

Does setting your own keystore to javax.net.ssl.trustStore help?

String keystorePath = "local.keystore";
System.setProperty("javax.net.ssl.trustStore", keystorePath);

Be sure to check if you can read from that path (current example assumes local.keystore is in classpath.

Upvotes: 1

Related Questions