Java Fiddler 检查传出 SOAP 请求的设置?

Java settings for Fiddler examination of outgoing SOAP requests?

我正在尝试调试发送到第三方 Web 服务的 SOAP 请求。我的客户端代码(我本地机器上的代码 运行)是使用 wsimport 生成的。我正在尝试配置 Fiddler 以拦截我的传出 SOAP 请求,但没有成功。这是我到目前为止所做的:

  1. WinINET LAN 设置指向带有 Fiddler 运行 的本地主机 (127.0.0.1:8888) 并捕获流量。由于我的 Web 服务使用的是 HTTPS,因此我的 HTTPS 请求正在被 Fiddler 解密。此时我对第 3 方 URL 的请求根本没有出现。我收到一个堆栈跟踪错误,告诉我 Web 服务由于内部错误而无法处理请求(这就是我调试我的请求的原因 - 因为它是第三方,所以我无权访问 Web 服务日志)。

  2. 然后我将以下代码添加到调用 Web 服务的方法中:

    System.setProperty("http.proxyHost", "127.0.0.1");
    System.setProperty("https.proxyHost", "127.0.0.1");
    System.setProperty("http.proxyPort", "8888");
    System.setProperty("https.proxyPort", "8888");
    

当我执行包含此代码的代码时,收到以下错误:

org.apache.jasper.JasperException: javax.xml.ws.WebServiceException: Failed to access the WSDL at: <wsdl_url>. It failed with: 
Got sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target while opening stream from <wsdl_url>.

但是在 Fiddler 中,我得到一个似乎未完成的请求条目(抱歉 - Fiddler 的新手)。主机列为 "Tunnel to" 并且显示为灰色。在 Fiddler 日志中,我收到此错误:

!SecureClientPipeDirect failed: System.Security.Authentication.AuthenticationException A call to SSPI failed, see inner exception. < An unknown error occurred while processing the certificate on pipe to (CN=<wsdl_base_url>, O=DO_NOT_TRUST, OU=Created by http://www.fiddler2.com).

对我来说,似乎我的 Fiddler 和我的代理配置正确,但我在 Java 中遗漏了一些东西。我忍不住觉得我在这里错过了一个关键步骤,所以任何建议都将不胜感激。谢谢!

编辑:我是否需要使用设置了 -httpproxy 选项的 wsimport 生成新的 Java 代码?

您需要将 Fiddler 的根证书添加到 Java 密钥库。 Java 不使用系统的证书存储,因此 Fiddler 将自己放在那里并不能解决您的问题。

通过在“工具”>“Fiddler 选项”>“HTTPS”中单击 Export Root Certificate 来获取 Fiddler 的证书。然后导入证书:http://azure.microsoft.com/en-us/documentation/articles/java-add-certificate-ca-store/#to-add-a-certificate-to-the-cacerts-store