Tracing the SOAP envelope that is being sent by a .NET web service client possible?

15,800

Solution 1

If you're using a standard web service (not WFC), you can extend the SoapExtension class as described here:

http://www.blog.encoresystems.net/articles/how-to-capture-soap-envelopes-when-consuming-a-web-service.aspx

If you're using WFC, then you can implement IEndpointBehavior and IClientMessageBehavior as described here:

http://weblogs.asp.net/paolopia/archive/2007/08/23/writing-a-wcf-message-inspector.aspx

I use both, depending on whether I'm using web or service references.

Solution 2

You can use Fiddler, or System.Net tracing.

http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx http://msdn.microsoft.com/en-us/library/bb203855(BTS.10).aspx

Solution 3

You can use fiddler, perhaps, as a proxy and thus monitor HTTP/HTTPS requests. This won't require you to write any code on your part.

Fiddler Web Debugger

It is worth noting that there are caveats to debugging HTTPS requests with Fiddler. This page explains how it can be done.

Fiddler Web Debugger - Debugging HTTPS traffic with Fiddler2

Share:
15,800
Uwe Keim
Author by

Uwe Keim

German developer. Some of my apps: SharePoint Systemhaus Göppingen (zwischen Stuttgart und Ulm) Eigene Homepage erstellen Test Management Software Windows 10 Ereignisanzeige Very proud father of Felix (2012) and Ina (2014). Loves running, climbing and Indian food. Code Project member #234.

Updated on June 12, 2022

Comments

  • Uwe Keim
    Uwe Keim almost 2 years

    A C# client application we developed calls an external SOAP web service of a third party company.

    Now I want to trace the exact SOAP request envelopes that are being generated by the VS.NET-generated SOAP proxy in our application and transfered to the external SOAP web service.

    The method of using a network monitor like Wireshark (as described here) or using Microsoft Network Monitor is no option since the externl SOAP web service only provides an SSL/HTTPS URL, so the payload of the HTTP packages are encrypted and not viewable.

    My question is:

    Is there a way of configuring the .NET-built-in web service client classes to output/trace/log their underlying HTTP requests and responses that are being generated/received? (or maybe some kind of event to subscribe to?)

  • Martin Clarke
    Martin Clarke over 14 years
    +1 for the SoapExtension, used that successfully too. OP didn't mention if it was web/windows client. If web, then I don't believe the SoapExtenstion code in the link is websafe.