尝试通过https执行web服务时出现此异常。这个异常发生在我尝试获取服务实例的运动中。 我按照以下步骤使用wsImport.exe工具生成webservice客户端。javax.net.ssl.SSLException:无效填充长度
我manualy下载的WSDL从网站
二手wsimport工具生成客户端java文件
- 新增的java文件到我的项目在eclipse
写了一个测试客户端如下测试服务实例
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")); }
与上面的代码我下面execption
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)
每次我执行,在前OT“无效垫长度”的数字是不同的。这次是76和50.其他时间是67,106.等
请帮忙, 我使用的是最新版本的Java,即1.8.0_51。
我应该在哪里使用bouncycastle? – Ravi