While working on winning Netflix' million, I came across a need to examine the raw XML returned by a third party web service. After a couple desk-pounding hours, I finally found a simple solution which works equally well in both Web and Windows apps.
- Install Web Services Enhancements (WSE) 3.0
- Add a project reference to Microsoft.Web.Services3
- Modify the web service proxy to inherit from Microsoft.Web.Services3.WebServicesClientProtocol instead of System.Web.Services.Protocols.SoapHttpClientProtocol. (This augments the proxy's capabilities.)
- The response's raw XML may then be retrieved immediately after the call to Invoke as ResponseSoapContext.Envelope.InnerXml
Optionally, log4net may be employed so as not to interrupt the application while it goes about its business...
- Add a project reference to log4net
- Add log4net configuration to app.config or web.config. For example:
<!-- If you want to turn log4net off completely,
include threshold="OFF" below -->
value="%d [%t] %-5l - %m%n%n"/>
<!-- ALL, DEBUG, INFO, WARN,
ERROR, FATAL, OFF-->
- Initialize log4net when the application starts with a call to XmlConfigurator.Configure();
- Add the following code immediately after the call to Invoke in the proxy web service:
log4net.ILog logger = log4net.LogManager.GetLogger(typeof(MyProxyClassName));
With log4net turned on, the raw XML within the web service response will get written out to the log file and the application will not be interrupted.
10-09-2006 4:29 PM