Is there a way to configure Fiddler to intercept HTTP calls from a Windows service?
We're in the process of replacing an old (5+ years) Windows service application built with VS2005 that makes an HTTP GET call. There are several things that make this difficult (such as the web server is on the customer's network and we can't connect directly to it) and, unfortunately, we'd prefer not to take down the running system to replace it with a WinForm version that can be monitored by Fiddler. The new code appears to be doing everything correctly, but, alas, it is failing to authenticate.
Is there a way to configure Fiddler (2.2.9.1) to 开发者_JAVA百科intercept HTTP calls from a Windows service?
Codeka provided a clue to get me going in the right direction. The piece that was still missing was how to get the proxy configured. The <appname>.exe.config
needs <defaultProxy>
specified to have a section like the following added:
<configuration>
<!-- The `<system.net>` element is an immediate child of `<configuration>` but can appear anywhere in app.config -->
<system.net>
<defaultProxy enabled="true">
<proxy proxyaddress="http://127.0.0.1:8888" bypassonlocal="False"/>
</defaultProxy>
</system.net>
</configuration>
Once this was done the Windows service's http traffic started flowing through Fiddler.
Fiddler just acts as an HTTP proxy, so if you can configure a proxy in your service then you can configure it to go through Fiddler. Whether that's possible is hard to say...
If that doesn't work, you could do it by running Fiddler on a second computer and configuring it to listen on port 80. Then on your "test" computer, edit your hosts file so that it points to the second computer instead. So say the web service is on www.example.com, you set up your test server so that "www.example.com" points to your second computer (running Fiddler). Then, when the service goes to connect to "www.example.com" it'll actually connect to Fiddler. Fiddler will then forward the connection to the real www.example.com after recording the request/response.
I haven't tested the above, but I think it would work. Obviously, if you can configure the proxy settings in your service that would be easier!
And, of course, if Fiddler doesn't work there's always Wireshark. As a hint, use a couple filters in Wireshark (e.g. show only packets going to or coming from the destination IP) to avoid feeling like you're being overrun with data.
As .NET bypasses proxies for localhost and 127.0.0.1, just hardcode your machine name instead for the url you're testing with.
//myUrl = "http://127.0.0.1/myservice";
myUrl = "http://mymachine/myservice";
Note: Important: Regardless of other settings, .NET will always bypass the Fiddler proxy for URLs containing localhost. So, rather than using localhost, change your code to refer to the machine name. For instance:
This URL will not appear in Fiddler:
http://localhost/X509SignCodeService/X509SigningService.asmx This URL will appear in Fiddler:
精彩评论