Skip to main content

Debug SOAP request and response in WCF

Often while working with SOAP service integrations I would like to see the actual SOAP envelope that is passed around. This is not trivial while working with WCF, because it effectivly hide the implementation details. You'll will have to turn on WCF message debugging.

That is done in web.config.

<?xml version="1.0" encoding="utf-8" ?>
      <source name="System.ServiceModel.MessageLogging">
          <add name="xml"/>
      <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Traces.svclog" />

<system.serviceModel> <diagnostics wmiProviderEnabled="true"> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" /> </diagnostics> </system.serviceModel> </configuration>

When you run your code a file called Traces.svclog should be created in your output directory. In a website this would be root of the site, and in a native application, this would be the bin folder.

You can open it in Microsoft Service Trace Viewer or just an ordinary text editor.

Microsoft Services Trace Viewer

I find this very useful when dealing with services from other companies, where as I can really say - I'm sending this SOAP request and I'm recieving this response. That's not expected, is it?

If you're having trouble getting this to work, you may look at my sample application, that fetches the currency conversion rate from an open webservice at

comments powered by Disqus