I'd like to log the parameters that were passed to any of the functions
in my webservice. Is there an easier way to get the parameters from the
Request[]? I wrote this function and for simple functions it works:
XmlDocument GetRequestXml() {
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateElement("request"));
foreach(string key in this.Context.Request.Form.AllKeys) {
XmlElement x = doc.CreateElement(key);
x.InnerXml =
Server.HtmlEncode(this.Context.Request.Form[key]);
doc.DocumentElement.AppendChild(x);
}
foreach(string key in this.Context.Request.QueryString.AllKeys)
{
XmlElement x = doc.CreateElement(key);
x.InnerXml =
Server.HtmlEncode(this.Context.Request.QueryString[key]);
doc.DocumentElement.AppendChild(x);
}
return doc;
}
However if I have a function like this:
[WebMethod]
public string Test1(string[] test) {
...
}
In this case GetRequestXml returns nothing (<request />). I have
methods with lots of parameters and all I want it to log the passed
parameters so I can figure out what happens if something crashed and
debug the service easier.