Tracing SOAP Messages in WCF

Saturday, August 2, 2008

This is a nice feature that comes with WCF (Windows Communication Foundation) with regards to debugging SOAP messages.  With VS 2005, out of the box there is no way to trace message when your message is not well formed and cannot be parsed.  You have to download WSE 3 or another third party tool like Contract First to assist in debugging.


WCF in VS 2008 comes with a neat tool out of the box called SvcTraceViewer.exe.  To use it, you configure your service to log events when a message is made.  To do that you use the following configuration:


    <!-- add trace logging -->
    <diagnostics wmiProviderEnabled="true">

  <!-- define trace logging -->
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true" >
          <add name="xml"/>
      <source name="System.ServiceModel.MessageLogging">
          <add name="xml"/>
      <add name="xml"
           initializeData="C:\logs\CommandLineSTS.svclog" />



Once your service is configured to log messages you can then use the tool to see the SOAP message and whatever exception were captured.  Below is a sample SOAP call to the QuickSell message logged.



comments powered by Disqus