Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 499
David Chappelle Avatar asked Nov 20 '08 21:11

David Chappelle


People also ask

What does << mean in C?

<< is the left shift operator. It is shifting the number 1 to the left 0 bits, which is equivalent to the number 1 .

What does %d do in C?

In C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs.


2 Answers

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.

like image 92
Zachary Yates Avatar answered Oct 14 '22 12:10

Zachary Yates


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.

like image 24
Moose Avatar answered Oct 14 '22 12:10

Moose