views:

2069

answers:

4

I have a C# application that is a client to a web service. One of my requirements is to allow capturing the SOAP that I send, so that if there is a problem, I can either fix the bug, or demonstrate that the problem is in the service I am calling.

My WebReference proxy service class derives from System.Web.Services.Protocols.SoapHttpClientProtocol as usual. If I had a magic wand, I would make this base class implement an event OnPost that I could handle to write the SOAP into my logs and continue.

Short of running a packet sniffer like WireShark, is there an easy way to get this level of logging?

+3  A: 

I think what you are looking for is in this post. It looks like a lot of code though.

Hope that helps!

Zachary Yates
SoapExtension is not the ideal solution (need to manage state, affects ALL soap calls and not just the ones you want to log) but it does work. Thanks!
David Chappelle
+1  A: 

Take a look at SoapExtensions.

They are what you need.

FlySwat
Thanks, that is what I needed.
David Chappelle
+1  A: 

If the application is running on your local box and the web service isn't doing anything funky, you can use Fiddler. Fire Up IE, run Fiddler, and you'll see your web service calls go through fiddler's proxy too.

I just used this this morning to do almost the same thing. I had to prove the data my web service was sending wasn't messed up.

Moose
A: 

For some reason Fiddler was not showing my local service calls when using the ASP.NET Development Server that comes with Visual Studio. To get around this I changed the web service Url at runtime to be the Fiddler port, just to capture the SOAP message.

You can do this from the Immediate window, for example:

myservice.Url = "localhost:8888" (or whatever port you have Fiddler on)

I used the SoapUI client to test responses.

Rob Kent