在 Java 和 Eclipse 中使用 fiddler
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7433720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using fiddler with Java and Eclipse
提问by Dr.Bunny
I'm trying to hook up fiddler to a java unit test in Eclipse so I can see the soap request when our web service is being called...It works automatically in our .NET harness but is there some setting that needs to be applied for Java? Thanks
我正在尝试将 fiddler 连接到 Eclipse 中的 java 单元测试,这样我就可以在调用我们的 Web 服务时看到soap请求……它在我们的 .NET 工具中自动工作,但是否有一些需要应用的设置为Java?谢谢
回答by parsifal
I have not tried this, but ...
我没有试过这个,但是......
Fiddler establishes itself as a proxy server, listening on localhost:8888
Fiddler 将自己建立为代理服务器,监听 localhost:8888
You can configure Java to use a proxy server with the http.proxyHost
and http.proxyPort
(see http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html).
您可以将 Java 配置为使用带有http.proxyHost
和的代理服务器http.proxyPort
(请参阅http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html)。
So, if you go into Eclipse and set the "VM" arguments to the following, it should route all traffic through Fiddler (which, of course, must be already running):
因此,如果您进入 Eclipse 并将“VM”参数设置为以下内容,它应该将所有流量路由到 Fiddler(当然,它必须已经在运行):
-Dhttp.proxyHost=localhost
-Dhttp.proxyPort=8888
This assumes that your application is using URLConnection
. If it's using Apache HttpClient or some other library, you may need to check the documentation for that library.
这假设您的应用程序正在使用URLConnection
. 如果它使用 Apache HttpClient 或其他一些库,您可能需要检查该库的文档。
回答by ZhaoGang
I am usring Apache HttpClient(4.5.5), SWT 4, Fiddler 4, and the VM arguments method does not work for me. So I set the proxy settings in the code and it works.
我正在使用Apache HttpClient(4.5.5)、SWT 4、Fiddler 4,VM 参数方法对我不起作用。所以我在代码中设置了代理设置并且它起作用了。
HttpHost proxy = new HttpHost("localhost", 8888, "http");
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
CloseableHttpClient httpclient = HttpClients.custom()
.setRoutePlanner(routePlanner)
.build();