wsimport 帶https協議wdsl 時報錯的處理
最近用wsimport處理 帶https協議wdsl 時報錯:
E:\Projects\Sample>wsimport -s ./src -verbose https://localhost:8743/hello?wsdl
正在解析 WSDL...
[ERROR] sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
無法讀取 WSDL 文件: https://localhost:8743/hello?wsdl, 原因為 1) 找不到文件; 2) 無法讀取文件; 3) 文件的根元素不是 <wsdl:definitions>。
[ERROR] failed.noservice=在提供的 WSDL 中找不到 wsdl:service:
需要至少提供一個 WSDL, 該 WSDL 至少具有一個服務定義。
無法解析 WSDL。
大概是沒有找到證書的意思。
參考國外人士的意見,這樣處理:
E:\Projects\Sample>java -Djavax.net.ssl.trustStore=E:\MyProjects\SSL\server.keystore com.sun.tools.internal.ws.WsImport https://localhost:8743/hello?wsdl -p com.hjs.hello -s ./src
正在解析 WSDL...
OK啦。
當然,肯定有更好的方法,暫時沒找到去嘗試。有機會補上。