有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

javajavax。网ssl。SSLexException:填充长度无效

我在尝试通过https执行Web服务时遇到了这个异常。此异常发生在我尝试获取服务实例时。 我按照以下步骤使用wsImport生成webservice客户端。exe工具

  1. 我从网站手动下载了wsdl

  2. 使用wsImport工具生成客户端java文件

  3. 在eclipse中将java文件添加到我的项目中
  4. 编写了一个测试客户端,如下所示,以测试服务实例

    public static void main(String[] args) {
    
        String certificatesTrustStorePath = "c:/Apps/Java/jdk1.8.0_25/jre/lib/security/cacerts";
        // if I don't set the store path, I get below error 
        //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
    
        System.setProperty("javax.net.ssl.trustStore", certificatesTrustStorePath);
    
        URL wsdlLocation = null;
        String https_url ="https://localhost/services/WebService/wsdl/WebService.wsdl";
        try {
            wsdlLocation = new URL(https_url);
    
        } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        } 
    
        //This is the line where I get the below execption 
        WebServiceService webServiceService = new WebServiceService(wsdlLocation, 
            new QName("http://webservice.com", "WebServiceService"));  
    
    }
    

用上面的代码我在下面执行

    Exception in thread "main" com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.

javax.net.ssl.SSLException: Invalid Padding length: 76
javax.net.ssl.SSLException: Invalid Padding length: 50

at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
at javax.xml.ws.Service.<init>(Unknown Source)
at com.webservice.WebServiceService.<init>(WebServiceService.java:42)
at com.client.Client.main(Client.java:46)

每次执行时,前面的数字“无效焊盘长度”都是不同的。这一次是76和50。其他时间是67106。等等

请帮忙, 我使用的是最新版本的Java,即1.8.0_51


共 (2) 个答案

  1. # 1 楼答案

    Java8有这个问题。。。用Java7测试。同样的代码运行良好