Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?)

like image 873
Uwe Keim Avatar asked Nov 03 '09 19:11

Uwe Keim


People also ask

What is SOAP message in asp net?

SOAP (Simple Object Access Protocol) is a message protocol that enables the distributed elements of an application to communicate. SOAP can be carried over a variety of standard protocols, including the web-related Hypertext Transfer Protocol (HTTP).

How do I create a SOAP request and response in C #?

To make SOAP requests to the SOAP API endpoint, use the "Content-Type: application/soap+xml" request header, which tells the server that the request body contains a SOAP envelope. The server informs the client that it has returned a SOAP envelope with a "Content-Type: application/soap+xml" response header.

What is SOAP service in C#?

SOAP (Simple Access Object Protocol) is an XML based protocol and provides facility for applications written on different languages and running on different platforms to interact with each other. It works over HTTP. SOAP is a lightweight protocol as it is based on XML which is a lightweight language.


2 Answers

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.

like image 141
James Bailey Avatar answered Sep 19 '22 19:09

James Bailey


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

like image 31
meklarian Avatar answered Sep 22 '22 19:09

meklarian