log contents of request
|
| log contents of request | Hi All,
Is there a way to get the contents of a web service request? Preferably including the HTTP headers too. I tried saving Context.Request.InputStream to a stream, but it always appears to be 0 length. Is that because it's only used in a regular Page request and not for web services?
| | Jacob wrote:
> Hi All, > > Is there a way to get the contents of a web service request? > Preferably including the HTTP headers too. > I tried saving Context.Request.InputStream to a stream, but it always > appears to be 0 length. Is that because it's only used in a regular > Page request and not for web services? Check out: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h tml/frlrfsystemwebservicesprotocolssoapextensionclasstopic.asp (URL Wraps. Or use http://tinyurl.com/empf) Just dress your method with a [Trace( FileName="here">)] attribute and the request + response will be saved to the file. But this applies only to the XML. You can save the headers manually in the method itself. -- Deepak Shenoy http://shenoyatwork.blogspot.com
| | I have something like this in my HttpApplication subclass for tracing SOAP calls:
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
#if DEBUG //trace the request HttpRequest Request = HttpContext.Current.Request; Debug.WriteLine(Request.Headers["SOAPAction"]); byte[] bytes = new byte[Request.ContentLength]; Request.InputStream.Read(bytes, 0, bytes.Length); Request.InputStream.Position = 0; UTF8Encoding encoding = new UTF8Encoding(); Debug.WriteLine(encoding.GetString(bytes));
#endif }
|
|
|
|
|
 | Members Area | |
|
 | Last Web Marketing |
|
|
|
|
 | Last Programming Tips |
|
|
|
|
 | Last News |
|
|
|
|
|
|