How to use Fiddler to monitor WCF service
Asked Answered
S

12

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.

Selwin answered 7/1, 2011 at 20:10 Comment(1)
The WCF tracing services are pretty good by themselves including a nice GUI for viewing them. msdn.microsoft.com/en-us/library/ms751526.aspxStrage
S
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

Sammer answered 21/9, 2011 at 20:47 Comment(7)
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.Rogozen
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.Sawn
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.svcEustatius
For some reason didn't work for me (I'm using .svc web service). Eventually my workaround was to use catcher for windowsHooge
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 helpSammer
Thanks for the tips. Just a clarification, that new entry in web.config should be in the client side, not the WCF server side,Getty
I do not need to add that <system.net> section in web.config, just set Fiddler 4 for ReverseProxy works for me. But anyway thank you for giving me the direction.Loam
O
10

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"/>
Overexcite answered 5/5, 2014 at 12:31 Comment(0)
F
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!

Foreshorten answered 7/1, 2011 at 20:15 Comment(3)
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.Selwin
That's not quite accurate (and "power" is subjective, since WireShark cannot change traffic). See fiddler2.com/fiddler/help/reverseproxy.asp for more details on how to listen to inbound traffic.Psychotic
Eric - I suggest you state that in a standalone answer.Maugham
L
7

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
Lynden answered 18/11, 2015 at 17:2 Comment(0)
S
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

Semiporcelain answered 30/7, 2013 at 13:48 Comment(0)
M
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.

Maugham answered 7/1, 2011 at 22:39 Comment(0)
A
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>
Anonym answered 13/3, 2018 at 15:47 Comment(0)
F
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.

Fence answered 23/7, 2013 at 11:32 Comment(0)
W
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.

Wisp answered 13/8, 2019 at 14:24 Comment(0)
I
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

Ilario answered 15/9, 2019 at 5:44 Comment(0)
L
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

Libelant answered 11/6, 2021 at 3:8 Comment(0)
P
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

Palpable answered 28/10, 2021 at 10:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.