1
votes

I need to send request to my web service using https protocol. Using SOAP UI it's working fine and providing response for https request as well however if i am sending https request it's providing below exception javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://abc:8443/xyz/FileTransferService?wsdl. It failed with:

    sun.security.validator.ValidatorException: PKIX path building failed:       sun.security.provider.certpath.SunCertPathBuilderException: unable to find   valid certification path to requested target.
        at         com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:184)
       at    ##com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:166)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:131)
        at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:267)
       at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)

Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
         at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
         at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
         at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
      at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1497)
2

2 Answers

0
votes

If you want to use https, you just download the wsdl first, and make the wsdlLocation and url in your generated client class point to that file.

or generate your client like this

URL url = new URL("https://......?wsdl");
QName qname = new QName("NameSpace of the Service", "ServiceName");
Service service = Service.create(url, qname);

ServiceClass port= service.getPort(ServiceClass.class);

then you could can start to use the port.

You can find the example of later one in the website.

http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat-ssl-connection/

Oh, I forgot one thing. You have to add trust key in your java keystore. The following website shows the way to do it.

http://java.globinch.com/enterprise-java/security/pkix-path-building-failed-validation-sun-security-validatorexception/

0
votes

I know it is a quite old question but maybe an answer is never bad.

Normally this happens when the JVM cacerts file does not contains the root CA's certificate who signed your server SSL certificate. But be careful which JVM is running so which cacerts file you should edit. You can find the cacerts file under $JAVA_HOME/jre/lib/security/

If you are using glassfish 3 you should edit the cacerts.jks file under your specific domain config directory and not in the common JVM runtime folder.

Probably you have switched off the SSL certificate check in your SOAP UI.