如何为 WSDL 客户端生成目的导入 CA?
How to import CA for WSDL client generate purpose?
我得到了一个 WSDL 文件并要求我通过它创建一个 JAVA 客户端,所以我 运行 eclipse 4.5.2,创建了一个空的动态 web 项目,导入该 WSDL进入该项目,然后右键单击:
- Web 服务->生成客户端
- 设置配置:Tomcat7.0,Apache Axis
- 点击"Finish"弹出异常:PKIX构建路径失败
所以我查看了那个 WSDL,它包含一些需要连接到我们的测试服务的链接:
<soap:address location="https://example.com/testwebservice.svc" />
我查看了 Whosebug,似乎我需要从该 HTTPS 服务站点导入 CA。但是我不知道如何在未生成代码的情况下 "Import" 该 CA。
请告诉我如何解决这个问题,以便我继续开发,谢谢!
=====================
更新
我将该CA 导入我的cacerts 后,这个问题仍然存在?这很奇怪,因为我导出了这个 WSDL 将通过浏览器连接到的所有 CA(并且 keytool 一直告诉我这个 CA 在我第一次导入后已经存在)。
IWAB0399E Error in generating Java from WSDL: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xsd:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'https://example.com/CPP/download/xsd0.xsd', relative to 'file:/D:/project/java_client/java_client.wsdl'.: 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
javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xsd:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'https://example.com/CPP/download/xsd0.xsd', relative to 'file:/D:/project/java_client/java_client.wsdl'.: 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
at com.ibm
使用此服务涉及几个步骤。
Get/Extract 公开服务证书。这可以通过要求该服务的开发人员提供证书来完成,或者您可以使用浏览器访问该服务并在可能的情况下提取证书。
找到 java 的默认信任库。 Java/JRE 附带位于 Java 安装中的全局信任库。找到 cacerts 文件。该文件应该在 /jre/lib/security 中可用。
将证书导入信任库。使用 keytool 命令导入 cacerts 文件中的 webservice 证书。
keytool -import -v -trustcacerts -alias server-alias -file server.cer -keystore cacerts -keypass changeit -storepass changeit
请注意,这不是推荐的方法,因为这只会信任当前 server/workstation 上的证书,并且此文件可能会在下一次 java 升级时被覆盖。您需要在部署此应用程序的任何地方执行此步骤。
虽然您需要执行上述步骤来创建服务代理(Eclipse/Apache 轴项目生成)
我得到了一个 WSDL 文件并要求我通过它创建一个 JAVA 客户端,所以我 运行 eclipse 4.5.2,创建了一个空的动态 web 项目,导入该 WSDL进入该项目,然后右键单击:
- Web 服务->生成客户端
- 设置配置:Tomcat7.0,Apache Axis
- 点击"Finish"弹出异常:PKIX构建路径失败
所以我查看了那个 WSDL,它包含一些需要连接到我们的测试服务的链接:
<soap:address location="https://example.com/testwebservice.svc" />
我查看了 Whosebug,似乎我需要从该 HTTPS 服务站点导入 CA。但是我不知道如何在未生成代码的情况下 "Import" 该 CA。
请告诉我如何解决这个问题,以便我继续开发,谢谢!
=====================
更新
我将该CA 导入我的cacerts 后,这个问题仍然存在?这很奇怪,因为我导出了这个 WSDL 将通过浏览器连接到的所有 CA(并且 keytool 一直告诉我这个 CA 在我第一次导入后已经存在)。
IWAB0399E Error in generating Java from WSDL: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xsd:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'https://example.com/CPP/download/xsd0.xsd', relative to 'file:/D:/project/java_client/java_client.wsdl'.: 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
javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xsd:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'https://example.com/CPP/download/xsd0.xsd', relative to 'file:/D:/project/java_client/java_client.wsdl'.: 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
at com.ibm
使用此服务涉及几个步骤。
Get/Extract 公开服务证书。这可以通过要求该服务的开发人员提供证书来完成,或者您可以使用浏览器访问该服务并在可能的情况下提取证书。
找到 java 的默认信任库。 Java/JRE 附带位于 Java 安装中的全局信任库。找到 cacerts 文件。该文件应该在 /jre/lib/security 中可用。
将证书导入信任库。使用 keytool 命令导入 cacerts 文件中的 webservice 证书。
keytool -import -v -trustcacerts -alias server-alias -file server.cer -keystore cacerts -keypass changeit -storepass changeit
请注意,这不是推荐的方法,因为这只会信任当前 server/workstation 上的证书,并且此文件可能会在下一次 java 升级时被覆盖。您需要在部署此应用程序的任何地方执行此步骤。
虽然您需要执行上述步骤来创建服务代理(Eclipse/Apache 轴项目生成)