Share via


XML-RPC with WCF

UPDATE: The code has been updated. Ignore this post and go here.

I'm writing lots of code lately. I've rejoined the dasBlog community and I'm busy writing a prototype for the .NET Framework 3.5 version of dasBlog (we just released the 2.0 version, see https://www.dasblog.info/).

One of the goals of the prototype, which we'll eventually merge into the main codebase once the .NET Framework 3.5 is available at hosting sites is to standardize on WCF for all non-HTML endpoints. Since lots of the relevant inter-blog and blogging tool APIs are still based on XML-RPC, that called for an implementation of XML-RPC on WCF. I've just isolated that code and put it up on wcf.netfx3.com.

My XML-RPC implementation is a binding with a special encoder and a set of behaviors. The Service Model programming experience is completely "normal" with no special extension attributes. That means you can also expose the XML-RPC contracts as SOAP endpoints with all the advanced WCF bindings and features if you like.

The binding supports client and service side and is completely config enabled. Here's a snippet from the MetaWeblog contract:

[ServiceContract(Namespace = https://www.xmlrpc.com/metaWeblogApi)]
public interface IMetaWeblog : Microsoft.ServiceModel.Samples.XmlRpc.Contracts.Blogger.IBlogger
{
[OperationContract(Action="metaWeblog.editPost")]
bool metaweblog_editPost(string postid,
string username,
string password,
Post post,
bool publish);

   [OperationContract(Action="metaWeblog.getCategories")]
CategoryInfo[] metaweblog_getCategories( string blogid,
string username,
string password);
...
}

For your convenience I've included complete Blogger, MetaWeblog, and MovableType API contracts along with the respective data types in the test application. The test app is a small in-memory blog that you can use with the blogging function of Word 2007 as a client or some other blogging client for testing.

Of the other interesting XML-RPC APIs, the Pingback API has the following contract:

    [ServiceContract(Namespace="https://www.hixie.ch/specs/pingback/pingback")]
public interface IPingback
{
[OperationContract(Action="pingback.ping")]
string ping(string sourceUri, string targetUri);
}

and the WeblogUpdates API looks like this:

[DataContract]
public struct WeblogUpdatesReply
{
[DataMember]
public bool flerror;
[DataMember]
public string message;
}

[ServiceContract]
public interface IWeblogUpdates
{
[OperationContract(Action = "weblogUpdates.extendedPing")]
WeblogUpdatesReply ExtendedPing(string weblogName, string weblogUrl, string checkUrl, string rssUrl);
[OperationContract(Action="weblogUpdates.ping")]
WeblogUpdatesReply Ping(string weblogName, string weblogUrl);
}

I'm expecting some interop bugs since I've done a clean implementation from the specs, so if you find any please let me know.

The code is subject to the Microsoft samples license, which means that you can put it into your (blogging) apps. Enjoy.

Comments

  • Anonymous
    August 21, 2007
    PingBack from http://www.hanselman.com/blog/TheWeeklySourceCode2.aspx

  • Anonymous
    August 21, 2007
    This is very cool Clemens. I used XMLRPC for quite a few things back in they day, but i DO use blogger just now so very interested in playing around with this :)

  • Anonymous
    August 23, 2007
    I could get used to this rolling out of bed into my office thing BizTalk Server The highly anticipated