我正在尝试使用Ant构建文件从WSDL生成客户端jar,如下所示:
<target name="generateWSClient">
<setproxy proxyhost="proxy" proxyport="port" />
<wsimport wsdl="https://mywsdl" destdir="${build.dir}/clientclasses"
verbose="true" package="com.locationservice.client">
</wsimport>
<jar destfile="${build.dir}/${lis.jar.name}"
basedir="${build.dir}/clientclasses" />
<javac srcdir="${src.dir}" destdir="${build.dir}/clientclasses"
includes="com/locationservice/client/*.java">
<classpath refid="client.classpath" />
</javac>
</target>
但是当我运行Ant时,我得到了这个异常:
[wsimport] parsing WSDL...
[wsimport] [ERROR] sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[wsimport] Failed to read the WSDL document: https://mywsdl, 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>.
[wsimport] [ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s):
[wsimport] At least one WSDL with at least one service definition needs to be provided.
[wsimport] Failed to parse the WSDL.
任何指针如何解决这个问题?
我认为<wsimport>
中的https://mywsdl
必须指向有效的WSDL文档
看起来,您运行ant脚本的计算机没有用于外部服务器的适当证书。您正在尝试通过HTTPS访问WSDL,这可能需要安装证书。您可以从web浏览器访问WSDL吗?试一试:
HTTPS://mywsdl?wsdl
你应该得到你的wsdl-XML。如果有效,那么您应该检查在web浏览器中设置的证书。然后,您必须确定它们中的哪一个负责您的WSDL-Server,并且您应该在您的机器上安装此证书。
或者也许有一种方法可以在ANT调用中设置它…我不知道……
祝你好运!