Trace XML-RPC Response
If you need to see the XML being returned in an XML-RPC response when you are using XML-RPC.NET, attach an event handler to the proxy's ResponseEvent and trace the content of the stream using the Debug class. If you want to see the request XML, use RequestEvent.
using System.Diagnostics;
using System.IO;
using CookComputing.XmlRpc;
[XmlRpcUrl("http://www.cookcomputing.com/xmlrpcsamples/RPC2.ashx")]
public interface IStateName : IXmlRpcProxy
{
[XmlRpcMethod("examples.getStateName")]
string GetStateName(int stateNumber);
}
class Program
{
static void Main(string[] args)
{
IStateName proxy = XmlRpcProxyGen.Create<IStateName>();
proxy.ResponseEvent += (sender, e) => Debug.WriteLine(
new StreamReader(e.ResponseStream).ReadToEnd());
string name = proxy.GetStateName(1);
}
}
If you are using .NET 2.0 use an anonymous method:
proxy.ResponseEvent += delegate(object sender,
XmlRpcResponseEventArgs e)
{
Debug.WriteLine(new StreamReader(e.ResponseStream).ReadToEnd());
};
Posted by
Charles Cook
at 11:20 AM.
Permalink.
blog comments powered by Disqus.
Copyright © Charles Cook.