我想從wsdl文件生成存根文件,該文件可通過帶有自簽名證書的ssl連接到達。使用wsimport時的安全異常
<exec executable="wsimport">
<arg value="-d" />
<arg value="${absolute.path.to.project}/gen" />
<arg value="-s" />
<arg value="${absolute.path.to.project}/src" />
<arg value="https://host:8443/wsrf/services/WS?wsdl" />
</exec>
當我在螞蟻執行此,我得到這個錯誤:
generate-from-wsdl:
[exec] parsing WSDL...
[exec] [ERROR] sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[exec] Failed to read the WSDL document: https://192.168.56.101:8443/wsrf/services/KnowledgebaseWebservice?wsdl, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not <wsdl:definitions>.
[exec] [ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s):
[exec] At least one WSDL with at least one service definition needs to be provided.
[exec] Failed to parse the WSDL.
[exec] Result: 1
爲了避免這種情況,我想
- 導入與server.crt這文件
keytool -importcert -file ~/path/server.crt
- 將server.crt複製到$ JAVA_HOME/lib/security
UPDATE
我也試過如下:
<wsimport wsdl="https://host:8443/Webservice?wsdl" destdir="gen"
sourcedestdir="src"
verbose="true">
<jvmarg value="-Djavax.net.ssl.trustStore=/path/host.cer" />
<jvmarg value="-Djavax.net.ssl.trustStorePassword=changeit" />
</wsimport>
我仍然得到這個錯誤。我能做什麼?
螞蟻是否執行該你做的'密鑰工具-import'如相同的用戶? – sudocode
我不害怕:-)導入是作爲根(sudo),螞蟻作爲普通用戶執行的......但我正在研究另一個解決方案a.t.m.如果它工作,我將在這裏發佈 – strauberry
您可以下載WSDL的本地副本(以及任何引用的XSD文件),然後從本地副本生成存根。 –