16

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?

David Chappelle
  • 1,243
  • 5
  • 13
  • 29
  • Possible duplicate of [Getting RAW Soap Data from a Web Reference Client running in ASP.net](http://stackoverflow.com/questions/300674/getting-raw-soap-data-from-a-web-reference-client-running-in-asp-net) – gecco Dec 21 '16 at 07:21

6 Answers6

15

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.

Community
  • 1
  • 1
Zachary Yates
  • 12,966
  • 7
  • 55
  • 87
  • 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 Nov 20 '08 at 21:53
4

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
  • 5,354
  • 3
  • 33
  • 46
2

To see this traffic in fiddler use the following code:

mySoapHttpClientProtocol.Url = mySoapHttpClientProtocol.Url.Replace("localhost", "localhost.fiddler");

Otherwise, Visual Studio's built in web server will bypass all proxies.

bnieland
  • 6,047
  • 4
  • 40
  • 66
1

Take a look at SoapExtensions.

They are what you need.

FlySwat
  • 172,459
  • 74
  • 246
  • 311
0

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
  • 5,183
  • 4
  • 33
  • 54
0

Just "." add the address in your endpoint after "localhost". like this:

      <endpoint address="http://localhost.:8868/FEInvoice.asmx" binding="basicHttpBinding"
    bindingConfiguration="FEInvoice_Test" contract="EInvoiceIntegration.FEInvoiceSoap"
    name="FEInvoice_Test" />
uzay95
  • 16,052
  • 31
  • 116
  • 182