long time ago I wrote webservice that is still in use. Now I plan to refactor it. The webservice is full of most likely unused functions and I have no idea how it is used by the clients. In order to strip away the unused functions I need to analyze the function calls and data of currently installed webservice.
Is there a (free/opensource) tool that will enable me to log all activities of the webservice.
The ideal output of the tool I’m looking for could be a database containing all the called functions and a list of the data that was send to it for each call.
Solution
With the help of Martins answer I created this HttpModule which does exactly what I wanted:
public class LoggingModule : IHttpModule { void IHttpModule.Init(HttpApplication context) { context.BeginRequest += new EventHandler(BeginRequest); } private void BeginRequest(object sender, EventArgs e) { TryAppendLog("Content-Type"); TryAppendLog("SOAPAction"); } void TryAppendLog(string key) { string value = HttpContext.Current.Request.Headers[key]; if (string.IsNullOrEmpty(value)) { return; } HttpContext.Current.Response .AppendToLog(string.Format("{0}: {1} ", key, value)); } #region IHttpModule Member public void Dispose() { } #endregion }
As Kobi wrote, you can find the required information in the IIS log files (i.e. in c:\WINDOWS\system32\LogFiles\W3SVC1).
If you want to log the usage into a database, you could write a simple HttpModule, which checks every request, and logs it into the DB if it is a call to your web service. E.g. here’s the relevant parts of a very simple HttpModule, which logs calls to mywebservice.asmx: