start | find | index | login or register | edit
netxr
by earl, 7802 days ago
.netXR - woohoo!

Update: lib is now compiled with .NET final

download: http://strain.at/earl/projects/strain.xmlrpc.dll

this is an xmlrpc client only library. server support will follow later. the client lib should be quite stable.

.netXR is an XML-RPC implementation for microsoft's .NET platform. as this sentence contains two acronyms beside .netXR's own, you might have two questions.

Contents
what is XML-RPC ?
what is .NET ?
so what is .netXR ?
getting started
a complete example


what is XML-RPC ?

Dave Winer: "It's a spec and a set of implementations that allow software running on disparate operating systems, running in different environments to make procedure calls over the Internet. It's remote procedure calling using HTTP as the transport and XML as the encoding. XML-RPC is designed to be as simple as possible, while allowing complex data structures to be transmitted, processed and returned." - http://www.xmlrpc.com/

XML-RPC is a remote procedure call specification relying on XML as encoding language. XML-RPC is a mechanism that - simply put - allows non-local functions to be called as if they were local. RPC is one mechanism underlying distributed computing.

XML-RPC is a very lightweight protocol that is easy to implement and therefore allows very stable implementations and has been implemented already on a whole bunch of platforms. For a plain english introduction you may like to read Dave Winer's XML-RPC for Newbiews.

Ultimately, XML-RPC allows Bob's application to call Lisa's functions, even if they are a thousand miles away of each other.

what is .NET ?

Andy McCullan: "That's difficult to sum up in a sentence. According to Microsoft, .NET is a 'revolutionary new platform, built on open Internet protocols and standards, with tools and services that meld computing and communications in new ways'. A more practical definition would be that .NET is a new environment for developing and running software applications, featuring ease of development of web-based services, rich standard run-time services available to components written in a variety of programming languages, and inter-language and inter-machine interoperability."

.NET is microsofts Next Big Thing and from a developers standpoint of view it seems quite promising. for a very good introdcution read Andy McCullan's DotNet FAQ.

so what is .netXR ?

Now that we have those acronyms explained: .netXR ist an XML-RPC implementation for the .NET platform. .netXR aims at ease of use and full .NET compliance.

getting started

It is our goal to make using xml-rpc in the .NET environment as easy as possible. And now let's really get started. Here is how to use the .netXR client library:
  1. Include the namespace strain.xmlrpc
  2. using strain.xmlrpc;
    Further you must add an reference to the library; when you use the command-line compiler just add an /r:xmlrpc.strain.dll.

  3. Instanciate a xml-rpc client object

  4. XmlRpcClient s = new XmlRpcClient( "betty.userland.com", "/RPC2", 80 );
    This object is now bound to the specified xml-rpc server and will handle all calls to this server.

  5. Now call procedures on this object
  6. s.Execute( "examples.getStateName", 17 );
    The first parameter is the 'procedure name', all other parameters will be passed on as parameteres to examples.getStateName. Execute directly returns the result of the RPC.

  7. XML-RPC <-> C# type mapping
  8. XML-RPC                 C#
    ------------------------------------------------------
    i4, int int
    boolean bool
    string string
    double double
    base64 char[]
    dateTime.iso8601 DateTime

    struct System.Collections.Hashtable
    array System.Collections.ArrayList
    Xmlrpc's types map quite straightforward to the types of the CLR (the foundation of .net). The handling of base64 data is left over to the application - if you need that, have a look at DecodeBase64.DecodeBuffer() and EncodeAsBase64.EncodeBuffer() in the System.Security.Cryptography namespace.
And now have fun with the simplicity of xmlrpc!

a complete example

namespace Test
{
  using System;
  using strain.xmlrpc;

  public class Test
  {
    public static int Main(string[] args)
    {
      XmlRpcClient server =
        new XmlRpcClient( "betty.userland.com", "/RPC2", 80 );
      string resp = (string)server.Execute( "examples.getStateName", 1 );
      Console.WriteLine( "Response: {0}", resp );

      return 0;
    }
  }
}


gratitudes fly out to
Chris Langreiter for keeping earl motivated
Dave Winer for his fine work (namely the XML-RPC spec)
(more to come ...)

- earl and tsr
Copyright (C) 2001 by earl and tsr
powered by vanilla
echo earlZstrainYat|tr ZY @.
earl.strain.at • esa3 • online for 8425 days • c'est un vanilla site