如何使用 Apache cxf 为安全 (https) soap Web 服务生成 java 类

How to generate java classes for secured(https) soap web service using Apache cxf

我尝试通过以下 url https://example.com:20008/mws-ws/services/TL_M3_PRSystem_Integration?wsdl 生成 Web 服务 类 此 Web 服务在特定 VPN 下运行。

我使用 apache cxf 为该 Web 服务生成 java 类。

然后我在 cmd 上遇到以下错误,

当我使用不安全的 soap 网络服务时,我可以生成 类。

有人知道吗?

它很可能是由 self-signed(不受信任的)证书签名的。最简单的方法是将此证书添加到 cacerts java 密钥库或将其添加到自定义存储和 运行 wsimportjavax.net.ssl.trustStore 属性设置为自定义商店。

  1. 转到 Chrome 中的 url 并使用开发工具中的“安全”选项卡将证书导出到文件。
  2. 使用 keystore 工具将证书导入 cacerts 密钥库。

在终端中:

$JAVA_HOME/bin/keytool -import -alias MyCustomCert -keystore $JAVA_HOME/jre/lib/security/cacerts -file ~/path/to/saved/cert

或 Windows:

%JAVA_HOME%\bin\keytool -import -alias MyCustomCert -keystore %JAVA_HOME%\jre\lib\security\cacerts -file C:\whereever\the\file\is

确保已定义 JAVA_HOME 环境变量并且您使用的命令提示符具有写入 %JAVA_HOME%\jre\lib\security\cacerts 文件的权限。