Wednesday, July 30, 2008

Capturing and viewing WCF SOAP messages

When using WCF it is sometimes required to examine the incoming and outgoing SOAP messages. You can do this by modifying your WCF configuration file, then viewing the messages using a utility installed alongside Visual Studio.

The easiest way configure your configuration file is to use the Visual Studio menu,
Tools | WCF Service Configuration Editor. Use the utility to open up your WCF configuration file (the place where all your WCF endpoints are defined). Next, access the Diagnostics section to enable logging for incoming and outgoing SOAP messages (Message Logging in the tree view). There are various options in the right pane of the display. If you want to see the entire SOAP messages, be sure to enable the LogEntireMessage option in the Message Logging section (it took me a while to figure out this one).

Perform a File | Save and now your WCF configuration should be ready to go. When you run your WCF application, a new xxxx.svclog file will be created in the root directory of your Visual Studio project (you can change this via the WCF configuration file).

To view the message log file, use the SvcTraceViewer.exe program from Microsoft. It’s normally located in \Program Files\Microsoft SDKs\Windows\v6.0A\Bin. Use the File | Open to find the xxxx.svclog file. There are several different ways to view your data. I like the "Messages" view the best.

When you are done with your diagnostics, you can use the WCF Service Configuration Editor to disable logging.

No comments:

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...