110

I have a WCF service that accepts a complex type and returns some data. I want to use Fiddler to see what the incoming requests to the service looks like. The client is .net console app which uses a Service reference proxy. Is this possible with Fiddler. I'm new to this tool and have only used it in the past to post data with the request builder.

Quadwwchs
  • 1,425
  • 3
  • 15
  • 20
  • 4
    The WCF tracing services are pretty good by themselves including a nice GUI for viewing them. http://msdn.microsoft.com/en-us/library/ms751526.aspx – kenny Jan 08 '11 at 00:40

12 Answers12

150

You need to add this in your web.config

<system.net>
  <defaultProxy>
    <proxy bypassonlocal="False" usesystemdefault="True" proxyaddress="http://127.0.0.1:8888" />
  </defaultProxy>
</system.net>
  1. then Start Fiddler on the WEBSERVER machine.
  2. Click Tools | Fiddler Options => Connections => adjust the port as 8888.(allow remote if you need that)
  3. Ok, then from file menu, capture the traffic.

That's all, but don't forget to remove the web.config lines after closing the fiddler, because if you don't it will make an error.

Reference : http://fiddler2.com/documentation/Configure-Fiddler/Tasks/UseFiddlerAsReverseProxy

Brad Rem
  • 6,036
  • 2
  • 25
  • 50
Tarek El-Mallah
  • 4,015
  • 1
  • 31
  • 46
  • 1
    Thanks, that really helped me too. My mistake was not to specify `http://` in proxy address. All the rest was the same, as you've mentioned. – Johnny_D Aug 29 '13 at 12:26
  • 1
    This did not work for me.My situation is: server is IIS7.5,client is a console application.In my console app,I called a WebService method which is deployed on IIS7.5 on my develop computer.Replacing "localhost" with my computer name worked for me. – york Jan 10 '14 at 03:24
  • 5
    Thanks, it worked for me. By the way, in my case I tried to capture WCF client traffic on **localhost**, so apart from adding your settings, it also needed to change the URL from `http://localhost/abc.svc` to `http://HOSTNAME/abc.svc` – cateyes Aug 21 '14 at 01:31
  • 1
    For some reason didn't work for me (I'm using .svc web service). Eventually my workaround was to use [catcher](https://github.com/ren85/catcher) for windows – ren Jul 27 '15 at 15:47
  • Sometimes it doesn't work in some cases (like in case of using localhost, or using HTTPS urls), so check the configuration of the Port/ and HTTPs encryption, and let me know details, maybe I could help – Tarek El-Mallah Jul 28 '15 at 18:09
  • 1
    Thanks for the tips. Just a clarification, that new entry in web.config should be in the client side, not the WCF server side, – Paul L Nov 08 '17 at 19:06
  • 1
    I do not need to add that section in web.config, just set Fiddler 4 for ReverseProxy works for me. But anyway thank you for giving me the direction. – IcyBrk Dec 10 '17 at 00:32
9

Just had this problem, what worked for me was to use localhost.fiddler:

 <endpoint address="http://localhost.fiddler/test/test.svc"
            binding="basicHttpBinding" 
            bindingConfiguration="customBinding" 
            contract="test" 
            name="customBinding"/>
L-Four
  • 13,345
  • 9
  • 65
  • 109
9

Fiddler listens to outbound requests rather than inbound requests so you're not going to be able to monitor all the requests coming in to your service by using Fiddler.

The best you're going to get with Fiddler is the ability to see all of the requests as they are generated by your Console App (assuming that the app generates web requests rather than using some other pipeline).

If you want a tool that is more powerful (but more difficult to use) that will allow you to monitor ALL incoming requests, you should check out WireShark.

Edit

I stand corrected. Thanks to Eric Law for posting the directions to configuring Fiddler to be a reverse proxy!

Justin Niessner
  • 242,243
  • 40
  • 408
  • 536
  • Thanks for the info. I need to view the request structure similar to the description page for asmx services. WCF doesn't seem to have this option. – Quadwwchs Jan 07 '11 at 20:40
  • 10
    That's not quite accurate (and "power" is subjective, since WireShark cannot change traffic). See http://www.fiddler2.com/fiddler/help/reverseproxy.asp for more details on how to listen to inbound traffic. – EricLaw Jan 07 '11 at 21:14
  • Eric - I suggest you state that in a standalone answer. – Cheeso Jan 07 '11 at 22:37
6

Consolidating the caveats mentioned in comments/answers for several use cases.

Mostly, see http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/ConfigureDotNETApp

  • Start Fiddler before your app
  • In a console app, you might not need to specify the proxyaddress:

    <proxy bypassonlocal="False" usesystemdefault="True" />
    
  • In a web application / something hosted in IIS, you need to add the proxyaddress:

    <proxy bypassonlocal="False" usesystemdefault="True" proxyaddress="http://127.0.0.1:8888" />
    
  • When .NET makes a request (through a service client or HttpWebRequest, etc) it will always bypass the Fiddler proxy for URLs containing localhost, so you must use an alias like the machine name or make up something in your 'hosts' file (which is why something like localhost.fiddler or http://HOSTNAME works)
  • If you specify the proxyaddress, you must remove it from your config if Fiddler isn't on, or any requests your app makes will throw an exception like:

    No connection could be made because the target machine actively refused it 127.0.0.1:8888

  • Don't forget to use config transformations to remove the proxy section in production
drzaus
  • 24,171
  • 16
  • 142
  • 201
4

So simple, all you need is to change the address in the config client: instead of 'localhost' change to the machine name or IP

Ziv.Ti
  • 609
  • 7
  • 10
1

This is straightforward if you have control over the client that is sending the communications. All you need to do is set the HttpProxy on the client-side service class.

I did this, for example, to trace a web service client running on a smartphone. I set the proxy on that client-side connection to the IP/port of Fiddler, which was running on a PC on the network. The smartphone app then sent all of its outgoing communication to the web service, through Fiddler.

This worked perfectly.

If your client is a WCF client, then see this Q&A for how to set the proxy.

Even if you don't have the ability to modify the code of the client-side app, you may be able to set the proxy administratively, depending on the webservices stack your client uses.

Community
  • 1
  • 1
Cheeso
  • 189,189
  • 101
  • 473
  • 713
1

Standard WCF Tracing/Diagnostics

If for some reason you are unable to get Fiddler to work, or would rather log the requests another way, another option is to use the standard WCF tracing functionality. This will produce a file that has a nice viewer.

Docs

See https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/tracing-and-message-logging

Configuration

Add the following to your config, make sure c:\logs exists, rebuild, and make requests:

  <system.serviceModel>
    <diagnostics>
      <!-- Enable Message Logging here. -->
      <!-- log all messages received or sent at the transport or service model levels -->
      <messageLogging logEntireMessage="true"
                      maxMessagesToLog="300"
                      logMessagesAtServiceLevel="true"
                      logMalformedMessages="true"
                      logMessagesAtTransportLevel="true" />
    </diagnostics>
  </system.serviceModel>

  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information,ActivityTracing"
        propagateActivity="true">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="C:\logs\TracingAndLogging-client.svclog" type="System.Diagnostics.XmlWriterTraceListener"
        name="xml" />
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>
Seth Flowers
  • 8,990
  • 2
  • 29
  • 42
0

I have used wire shark tool for monitoring service calls from silver light app in browser to service. try the link gives clear info

It enables you to monitor the whole request and response contents.

DiAgo
  • 351
  • 4
  • 6
0

I just tried the first answer from Brad Rem and came to this setting in the web.config under BasicHttpBinding:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding bypassProxyOnLocal="False" useDefaultWebProxy="false" proxyAddress="http://127.0.0.1:8888" ...
        ...
      </basicHttpBinding>
    </bindings>
    ...
<system.serviceModel>

Hope this helps someone.

0

You can use the Free version of HTTP Debugger.

It is not a proxy and you needn't make any changes in web.config.

Also, it can show both; incoming and outgoing HTTP requests. HTTP Debugger Free

Khachatur
  • 921
  • 1
  • 12
  • 30
0

Use fiddler a Reverse Proxy is the final solution for me.

First, configure fiddler as reverse proxy with REGDIT, like the doc said: https://docs.telerik.com/fiddler/configure-fiddler/tasks/usefiddlerasreverseproxy#configure-fiddler-as-reverse-proxy
1)Click Tools > Fiddler Options. Ensure Allow remote clients to connect is checked
2)Create a new DWORD named ReverseProxyForPort inside HKEY_CURRENT_USER\SOFTWARE\Microsoft\Fiddler2.
3)Set the DWORD to the local port where Fiddler will re-route inbound traffic.
4)Restart Fiddler.

Second, change the client to call service through proxy
for example , here is my client app.config:

<client>
    <endpoint address="http://localhost:61236/WeatherForecastService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWeatherForecastService"
        contract="ServiceReference1.IWeatherForecastService" name="BasicHttpBinding_IWeatherForecastService" />
</client>

change the client to use proxy endpoint address.

WeatherForecastServiceClient client = new WeatherForecastServiceClient("BasicHttpBinding_IWeatherForecastService", "http://localhost:8888/WeatherForecastService.svc");
var data = client.GetData(1000);
client.Close();

fiddler

ws_
  • 1,076
  • 9
  • 18
0

Change the localhost in the URL to localhost.fiddler, this small change worked for me.

Also if anyone testing the service from WCF Test Client don't forget to edit the URL in the config endpoint

  1. Right click on the config file
  2. Click Edit with Svc Config Editor
  3. Click on Endpoints and edit the endpoint to localhost.fiddler
  4. Check Start a new proxy while calling method

enter image description here

Nithya
  • 582
  • 8
  • 19