嘗試通過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