简体   繁体   English

javax.xml.ws.WebServiceException: 无法访问 WSDL

[英]javax.xml.ws.WebServiceException: Failed to access the WSDL

javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://xxxx.com/saw.dll?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.
Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://xxxxxxx.com/saw.dll?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:249)
    at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:230)
    at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:193)
    at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:162)
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:1917)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:301)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:295)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:145)

I faced this exception when i try to call soap web service method.当我尝试调用 soap web 服务方法时,我遇到了这个异常。 how can i solve this problem?我怎么解决这个问题?

I solved this exception and here is the class which helps me figure the problem out.我解决了这个异常,这里是 class,它帮助我解决了问题。 if you face this error when you call webservice method then please call allowSSL() method then call your ws call method.如果您在调用 webservice 方法时遇到此错误,请调用 allowSSL() 方法,然后调用您的 ws 调用方法。

import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public class FakeX509TrustManager implements X509TrustManager {

private TrustManager[] trustManagers;
private final X509Certificate[] _AcceptedIssuers = new X509Certificate[]{};

@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}

@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}

public boolean isClientTrusted(X509Certificate[] chain) {
    return true;
}

public boolean isServerTrusted(X509Certificate[] chain) {
    return true;
}

@Override
public X509Certificate[] getAcceptedIssuers() {
    return _AcceptedIssuers;
}

public void allowAllSSL() throws KeyManagementException {
    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    });
    SSLContext context = null;
    if (trustManagers == null) {
        trustManagers = new TrustManager[]{new FakeX509TrustManager()};
    }
    try {
        context = SSLContext.getInstance("TLS");
        context.init(null, trustManagers, new SecureRandom());
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
}

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 javax.xml.ws.WebServiceException:无法访问WSDL。 回复:'401:未经授权' - javax.xml.ws.WebServiceException: Failed to access the WSDL. Response: '401: Unauthorized' 调用 WSDL 服务时出现 javax.xml.ws.WebServiceException - javax.xml.ws.WebServiceException when invoking WSDL service javax.xml.ws.WebServiceException:找不到以wsdl命名的服务 - javax.xml.ws.WebServiceException: Could not find service named in wsdl 无法创建服务异常javax.xml.ws.WebServiceException: - Failed to create service exception javax.xml.ws.WebServiceException: javax.xml.ws.WebServiceException:不是有效的端口 - javax.xml.ws.WebServiceException: is not a valid port javax.xml.ws.WebServiceException:方法X暴露为WebMethod,但是没有对应的wsdl操作 - javax.xml.ws.WebServiceException: Method X is exposed as WebMethod, but there is no corresponding wsdl operation 出现CXF错误:javax.xml.ws.WebServiceException:WSDL元数据不可用于创建代理 - Getting CXF error: javax.xml.ws.WebServiceException: WSDL Metadata not available to create the proxy javax.xml.ws.WebServiceException:未定义的端口类型Java Struts SOAP WSDL - javax.xml.ws.WebServiceException: Undefined port type Java Struts SOAP WSDL javax.xml.ws.WebServiceException:org.apache.cxf.service.factory.ServiceConstructionException:创建服务失败 - javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service “ javax.xml.ws.WebServiceException:不是有效的服务。”代理问题? - “javax.xml.ws.WebServiceException: is not a valid service.” proxy issue?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM