Consider the requirement to log incoming SOAP requests to an ASP.NET ASMX web service. The task is to capture the raw XML being sent to the web service.
The incoming message needs to be logged for debug inspection. The application already has its own logging library in use, so the ideal usage would be something like this:
//string or XML, it doesn't matter.
string incomingSoapRequest = GetSoapRequest();
Logger.LogMessage(incomingSoapRequest);
- Are there any easy solutions to capture the raw XML of the incoming SOAP requests?
- Which events would you handle to get access to this object and the relevant properties?
- Is there anyway IIS can capture the incoming request and push to a log?
Best Answer
You can also implement by placing the code in Global.asax.cs
I have a Utility method in my web service that I use to capture the request when something happens that I am not expecting like a unhandled exception.
Then in web.config I store several AppSetting values that define what level I want to use to capture the request.
Then in my Application_BeginRequest I have it modified like so. Note that Configuration is a static class I create to read properties from web.config and other areas.