C# – In C#, how would I capture the SOAP used in a web service call

c++soapweb-services

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?

Best Solution

I think what you are looking for is addressed in this question:

Getting RAW Soap Data from a Web Reference Client running in ASP.net

It looks like a lot of code though.