java – 使用wsimport时的安全性异常

我想从wsdl文件生成存根文件,该文件可通过带有自签名证书的ssl连接访问.

<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>

当我在ant中执行此操作时,我收到此错误:

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

为了避免这种情况,我尝试了

>使用keytool -importcert -file~ / path / server.crt导入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>

我仍然得到这个错误.我能做什么?

解决方法:

我认为您需要通过指定-keystore< path_to> / jre / lib / security / cacerts将服务器证书导入JRE的密钥库.如果您坚持使用上一个命令行,我认为您需要为执行Ant的同一用户执行该命令.

上一篇:有钱还众筹软件APP系统定制开发


下一篇:软件开发工具(第7章:Eclipse入门)