Cook Computing

Interfaces and XML-RPC.NET Services

October 9, 2002 Written by Charles Cook

Before releasing the version of XML-RPC.NET with support for interface-based automatic generation of proxy classes, I'm enhancing the server side of the library to allow services to be defined via interfaces.

At the moment a service is implemented like this in C#:


public class MathService : XmlRpcService
{
  [XmlRpcMethod("math.Add")]
  public int Add(int A, int B)
  {
    return A + B;
  }
}

The custom attributes are specified on the methods of the class and it is not possible to use an interface (which could then be used in proxy class generation). So I'm currently modifying the XmlRpcServiceInfo class to check whether methods are derived from an interface and if so to check the interface methods for the custom attributes. This will allow a service to be implemented like this:


interface IMath
{
  [XmlRpcMethod("math.Add")]
  int Add(int A, int B);
}

public class MathService : XmlRpcService, IMath
{
  public int Add(int A, int B)
  {
    return A + B;
  }
}