Nikhil Thakral
Nikhil Thakral

Reputation: 55

How to log soap response which are sent by WCF

I am new to WCF. To log the SOAP request, I am referring to the following object: OperationContext.Current.RequestContext.RequestMessage and I flush it down to a file.

How can I achieve a similar functionality to log the SOAP response that will be sent by the OperationContract?

Upvotes: 3

Views: 3053

Answers (1)

tom redfern
tom redfern

Reputation: 31780

There are two ways of doing this.

  1. Implement WCF Tracing. This is more usually used for debugging rather than logging per se, because of the volume of data which is generated. However, the entire SOAP payloads of all requests and responses received will be logged. To view the logs you will need to use the WCF Trace Viewer.

  2. Implement service-or-client-side message inspectors to gain access to either the request message before handling or the response message before sending. This is a more targetted, fine-grained approach and is recommended over the WCF Tracing approach.

A third means is documented here: https://stackoverflow.com/a/52620878/569662

Upvotes: 3

Related Questions