How to use Fiddler to monitor WCF service

Posted panpanwelcome

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了How to use Fiddler to monitor WCF service相关的知识,希望对你有一定的参考价值。

https://stackoverflow.com/questions/4629800/how-to-use-fiddler-to-monitor-wcf-service

 

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

share  improve this answer   
  • 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 3: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 1:31 
  • 1
    For some reason didn‘t work for me (I‘m using .svc web service). Eventually my workaround was to use catcher for windows – ren Jul 27 ‘15 at 15:47
  • 2
    Awesome! The suggestion of @cateyes did it for me – Alexander Derck Nov 13 ‘15 at 12:14
     
     

    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

     

     

     

    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://docs.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:logsTracingAndLogging-client.svclog" type="System.Diagnostics.XmlWriterTraceListener"
            name="xml" />
        </sharedListeners>
        <trace autoflush="true" />
      </system.diagnostics>

以上是关于How to use Fiddler to monitor WCF service的主要内容,如果未能解决你的问题,请参考以下文章

how to use Inspector in fiddler

How To: Capture Android & iOS Traffic with Fiddler

How to use GITHUB to do source control

How to use GITHUB to do source control

How To Use the AWK language to Manipulate Text in Linux

How To Use Logstash and Kibana To Centralize Logs On CentOS 6