The Lua language
LuaXMLRPC Reference Manual
A Lua library for XMLRPC

home · data types · client · server · example · related docs


Introduction

LuaXMLRPC is a Lua library to manage XML-RPC clients and servers. It enables a Lua program to:

LuaXMLRPC provides a simple API and an abstraction layer over XML avoiding manipulation of string representation of data structures. It also offers ways to express everything when needed.

LuaXMLRPC is based on LuaExpat and on Lua 5.0.

Data types

XML-RPC elements are usually represented by the simplest correspondent Lua object. When the correspondance is not obvious, a Lua table is used with a field specifying the element.

From XML-RPC to Lua

When converting from XML-RPC element to a Lua object, a table with a field tag is used. The child elements are stored at numbered indexes and white space is ignored.
XML-RPC data type Lua object
double
int
i4
number
string string
boolean boolean
struct
arrray
table
other elements
{
  tag = "element name",
  [1] = <first child>,
  [2] = <second child>,
  [3] = ...,
}

From Lua to XML-RPC

A convertion from a Lua object to an XML-RPC can be made automatically or explicitly. The automatic conversion rules are:
Lua object XML-RPC data type
number double
string string
boolean boolean
{ key = val }
<struct>
  <member>
    <name>key</name>
    <value>val</value>
  </member>
</struct>
val is converted according to the same rules.
In case of a table that has numeric keys, the resulting struct will have numbers as keys (but they will be treated as strings).

Explicit conversions can be forced by the creation of typed values (see function createTypedValue).

Basic support

Client side

The client side library offers the following functions:

Example

Below is a small sample code displaying the use of the library in a client application.
require "xmlrpc"
require "luasocket"
require "xrh"

local ok, res = xrh.call ("http://www.oreillynet.com/meerkat/xml-rpc/server.php", "system.listMethods")
print (ok)
for i, v in pairs(res) do print ('\t', i, v) end

Related documentation

Here is a list of related documentation:

Contents

home · data types · client · server · example · related docs


Last modified on Tue Dec 9 14:52:18 BRST 2003