C# Web Services provide an easy interface to incoming SOAP data because the SOAP message has already been deserialised at the entry point of a WebMethod.
The downside is that sometimes you’ll need to have access to the full SOAP request: body, headers and everything for tasks such as diagnosing any errors (which message broke the web service) or providing graceful handling of third party web services.
At first you’d think that the Request object can provide this information with methods such as Request.BinaryRead() but unfortunately when you’re using SOAP all you get there is a querystring.
The solution here is to use the SOAP Extensions. Here is some sample code:
public class SoapMessageLogger : SoapExtension
public override void ProcessMessage(SoapMessage message)
// Do nothing on other states