I spent a bit of time googling for XMLRPC.NET client code and never found a good working sample, so here's the complete source in a Winforms app that displays blog titles via XMLRPC using the Metablog API in dotText. Thanks to Charles Cook for his work in making XML-RPC possible in .NET. Be sure to read his XMLRPC.NET FAQ for more info.
[XmlRpcUrl("http://mysite/myblog/services/metablogapi.aspx")]
public interface IGetRecentPosts
{
[XmlRpcMethod("metaWeblog.getRecentPosts")]
Post[] GetRecentPosts(string blogid, string username, string password, int numberOfPosts);
}
// TODO: following attribute is a temporary workaround
[XmlRpcMissingMapping(MappingAction.Ignore)]
public struct Enclosure
{
public int length;
public string type;
public string url;
}
// TODO: following attribute is a temporary workaround
[XmlRpcMissingMapping(MappingAction.Ignore)]
public struct Source
{
public string name;
public string url;
}
[XmlRpcMissingMapping(MappingAction.Ignore)]
public struct Post
{
[XmlRpcMissingMapping(MappingAction.Error)]
[XmlRpcMember(Description="Required when posting.")]
public DateTime dateCreated;
[XmlRpcMissingMapping(MappingAction.Error)]
[XmlRpcMember(Description="Required when posting.")]
public string description;
[XmlRpcMissingMapping(MappingAction.Error)]
[XmlRpcMember(Description="Required when posting.")]
public string title;
public string[] categories;
public Enclosure enclosure;
public string link;
public string permalink;
[XmlRpcMember(
Description="Not required when posting. Depending on server may "
+ "be either string or integer. "
+ "Use Convert.ToInt32(postid) to treat as integer or "
+ "Convert.ToString(postid) to treat as string")]
public object postid;
public Source source;
public string userid;
}
private void button1_Click(object sender, System.EventArgs e)
{
IGetRecentPosts proxy = (IGetRecentPosts)XmlRpcProxyGen.Create(typeof(IGetRecentPosts));
Post[] post = proxy.GetRecentPosts("69", "myusername", "mypassword", 5);
for (int i = 0; i < post.Length; i++)
{
listBox1.Items.Insert(0, post[i].title);
}
}
}