CShark
CShark

Reputation: 2221

Logging SOAP requests and responses

I have added a service reference to my application, with the appropriate proxy classes subsequently being generated.

In my code, I make use of these proxy classes to generate my service calls and to parse the results.

Because .Net takes care of the binding of the HTTP/HTTPS requests and responses, I am unable to view the exact SOAP requests that gets generated by my system.

How can I log the RAW http requests and responses that gets generated by the system, specifically by using Trace.Log, without having to use Fiddler or Wireshark or any other reverse proxy?

UPDATE

It is worth mentioning the following facts as well:


Upvotes: 2

Views: 2214

Answers (1)

BunkerMentality
BunkerMentality

Reputation: 1337

Have a look at implementing the IClientMessageInspector interface, it exposes two methods

AfterReceiveReply Enables inspection or modification of a message after a reply message is received but prior to passing it back to the client application.

BeforeSendRequest Enables inspection or modification of a message before a request message is sent to a service.

https://msdn.microsoft.com/en-us/library/System.ServiceModel.Dispatcher.IClientMessageInspector(v=vs.110).aspx

Here's a blog post that describes an implementation that reads the message in to raw xml, hopefully you'll be able to alter that to suit your needs http://westdiscgolf.blogspot.ie/2012/09/debugging-wcf-messages-before.html

Upvotes: 3

Related Questions