Cook Computing

CodeDOM and XML-RPC Proxies

February 18, 2003 Written by Charles Cook

Joe Bork is doing some cool work with the .NET CodeDOM. He has implemented some code to generate a CodeDOM representation of an XML-RPC.NET proxy based on an interface definition. This is then used to output source code for the proxy in whichever language you want (assuming the language supports CodeDOM). For example, given the following interface:


interface IHello
{
  [XmlRpcMethod]
  string Hello(string name);
}

Joe's XmlRpcProxyCodeGen class currently generates this C# proxy:


namespace HelloRpcProxy
{
  public sealed class HelloRpcProxy :     
    CookComputing.XmlRpc.XmlRpcClientProtocol, IHello
  {
    public HelloRpcProxy()
    {
    }
 
    [CookComputing.XmlRpc.XmlRpcMethodAttribute("Hello")]
    public string Hello(string param_0)
    {
      object tempVal = null;
      string retVal;
      object[] tempArr = new object[] {param_0};
      tempVal = this.Invoke("Hello", tempArr);
      retVal = ((string)(tempVal));
      return retVal;
    }
  }
}

Question 2.16 in the XML-RPC.NET FAQ is currently unanswered:

How do I implement a client in JScript.NET?

I've put off answering this because I know hardly anything about JScript.NET. But now I can include something based on this output from XmlRpcProxyCodeGen:


package HelloRpcProxy
{
  public final class HelloRpcProxy 
    extends CookComputing.XmlRpc.XmlRpcClientProtocol 
    implements IHello
  {
    public function HelloRpcProxy()
    {
    }
 
    public final CookComputing.XmlRpc.XmlRpcMethodAttribute("Hello") 
      function Hello(param_0 : System.String) : System.String
    {
       var tempVal : System.Object = null;
       var retVal : System.String;
       var tempArr : System.Object[] = [param_0];
       tempVal = this.Invoke("Hello", tempArr);
       retVal = System.String(tempVal);
       return retVal;
    }
  }
}

This will be a useful addition to the XML-RPC.NET library.