How to get raw data from Web Service Request?
I want to check raw data string (raw xml) received by my web service methods (for logging and debugging purposes).
I saw recommendations: to handle 'BeginRequest' event in HttpApplication. But I don't see which field of '开发者_高级运维Request' object contains this POST data?
Related question: Getting RAW Soap Data from a Web Reference Client running in ASP.net
- Have you seen this answer using tracing? or this one using a SoapExtension
I made following changes in web.cofig to get SOAP(Request/Response) Envelope. It makes trace.log file where all the required information are present
<system.diagnostics> <trace autoflush="true"/> <sources> <source name="System.Net" maxdatasize="1024"> <listeners> <add name="TraceFile"/> </listeners> </source> <source name="System.Net.Sockets" maxdatasize="1024"> <listeners> <add name="TraceFile"/> </listeners> </source> </sources> <sharedListeners> <add name="TraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="trace.log"/> </sharedListeners> <switches> <add name="System.Net" value="Verbose"/> <add name="System.Net.Sockets" value="Verbose"/> </switches>
It would not make sense to keep all the request post data in the request object since it could contain uploaded file and be very big.
I have two solutions for you:
1) Use Fiddler on the server and browse locally the website (using server name and not localhost since Fiddler cannot show localhost request/responses)
2) Use System.Net
tracing: http://support.microsoft.com/kb/947285
You can also use WireShark to look at the packets but this will not keep the request response context.
精彩评论