diff --git a/Makefile b/Makefile index 6b652ad..f698db8 100755 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ PKG= luaxmlrpc-$(VERSION) TAR_FILE= $(PKG).tar.gz ZIP_FILE= $(PKG).zip SRCS= README Makefile \ - xmlrpc.lua xrh.lua xrc.lua test.lua \ + xmlrpc.lua xmlrpc.http.lua xmlrpc.cgi.lua test.lua \ index.html manual.html license.html luaxmlrpc.png dist: diff --git a/README b/README index b717e59..5d1aac1 100755 --- a/README +++ b/README @@ -5,15 +5,15 @@ The standalone server depends on LuaSocket for Lua 5.0 also. Here goes a small description of the files in the distribution - index.html -- Home page - license.html -- Copyright & License - luaxmlrpc.png -- LuaXMLRPC Logo - Makefile -- Makefile for Unix systems - manual.html -- Reference manual - README -- This file - test.lua -- Overall API test script - xmlrpc.lua -- Source file - xrc.lua -- Extension server library over CGI - xrh.lua -- Extension server library over HTTP + index.html -- Home page + license.html -- Copyright & License + luaxmlrpc.png -- LuaXMLRPC Logo + Makefile -- Makefile for Unix systems + manual.html -- Reference manual + README -- This file + test.lua -- Overall API test script + xmlrpc.lua -- Source file + xmlrpc.http.lua -- Extension library over HTTP + xmlrpc.cgi.lua -- Server implementation over CGI $Id$ diff --git a/doc/manual.html b/doc/manual.html index f8e1469..b5ddf1f 100755 --- a/doc/manual.html +++ b/doc/manual.html @@ -53,31 +53,15 @@ 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.
-The abstraction layer over HTTP (xrh.lua
) depends on
+The abstraction layer over HTTP depends on
LuaSocket 2.0.
-
@@ -169,8 +153,10 @@ the resulting struct will have the string representation of these numbers
as keys (e.g. "1"
instead of 1
).
The library tries to convert integral numbers to integer types,
otherwise converting them to floating point numbers.
+
@@ -181,15 +167,15 @@ and decoding XML-RPC messages and for transforming data types between the
two representations.
Following is the list of functions.
client_encode (method_name, params*) => method_call
clEncode (method_name, params*) => method_call
methodCall
element.
It receives a string with the method's name and an optional list of
parameters.
The result is a string containing the XML-RPC document.
-
- client_decode (method_response) => ok, results
clDecode (method_response) => ok, results
methodResponse
element.
@@ -200,8 +186,8 @@ Following is the list of functions.
faultString and the faultCode.
This values are extracted from the fault
element.
-
- server_decode (method_call) => method_name, list_params
srvDecode (method_call) => method_name, list_params
server_encode (object, is_fault) => method_response
srvEncode (object, is_fault) => method_response
methodResponse
element.
It receives a Lua object (a number, a string, a table, a "created typed
value" etc.) with the return value of the call.
@@ -223,21 +209,23 @@ Following is the list of functions.
In this case, the Lua object must be a table with the members
faultCode
and faultString
.
-
- createTypedValue (object, type) => object
server_methods (tab_or_func)
srvMethods (tab_or_func)
-The file xrh.lua
implements a simple client side library
+The file xmlrpc.http.lua
implements a simple stand-alone client
based on LuaSocket 2.0.
The following function is provided:
call (url, method, params*)
method
at location url
with the given params
(if any).
+ The method
and params
parameters will be just
+ passed to
+ clEncode
+ function.
+ The result is the same as
+ clDecode
+ function: a boolean indicating whether the call was successful or not,
+ followed by the response value (if successful) or by the faultString
+ and the faultCode (if the call fails).
+
-The file xrc.lua
implements a simple XML-RPC server
+The file xmlrpc.cgi.lua
implements a simple XML-RPC server
using the package post
that can parse incoming POST data
from the http server.
An appropriate environment for writing Lua functions is implemented;
@@ -305,9 +304,9 @@ Below is a small sample code displaying the use of the library
in a client application.
-require "xrh" +require "xmlrpc.http" -local ok, res = xrh.call ("http://www.oreillynet.com/meerkat/xml-rpc/server.php", "system.listMethods") +local ok, res = xmlrpc.http.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@@ -322,11 +321,11 @@ XML-RPC.require "xmlrpc" -double_array_type = xmlrpc.createArray ("double") -double_array = xmlrpc.createTypedValue ( { 1.1, 2, 3, 4 }, double_array_type) +double_array_type = xmlrpc.newArray ("double") +double_array = xmlrpc.newTypedValue ( { 1.1, 2, 3, 4 }, double_array_type) -double_array_array_type = xmlrpc.createArray (double_array_type) -double_array_array = xmlrpc.createTypedValue ( +double_array_array_type = xmlrpc.newArray (double_array_type) +double_array_array = xmlrpc.newTypedValue ( { { 11, 12, 13, }, { 21, 22, 23, }, @@ -378,7 +377,7 @@ The tabledouble_array_array
will be: Follow a small example of a server based on a cgi launcher.-Note that the packagerequire "xrc" +require "xmlrpc.cgi" local kepler_home = "http://www.keplerproject.org" local kepler_products = { "luasql", "lualdap", "luaexpat", "luaxmlrpc", } @@ -389,7 +388,7 @@ local kepler_sites = { luaxmlrpc = kepler_home.."/luaxmlrpc", } -- Register methods -xmlrpc.server_methods { +xmlrpc.srvMethods { kepler = { products = function (self) return kepler_products end, site = function (self, prod) return kepler_sites[prod] end, @@ -399,13 +398,13 @@ xmlrpc.server_methods { local doc = {} post.parsedata (doc) -- Decode method call -local method, arg_table = xmlrpc.server_decode (doc[1]) +local method, arg_table = xmlrpc.srvDecode (doc[1]) local func = xmlrpc.dispatch (method) local ok, result, err = pcall (func, unpack (arg_table or {})) if ok then result = { code = 3, message = result, } end -respond (xmlrpc.server_encode (result, not ok) +respond (xmlrpc.srvEncode (result, not ok)post
and the functionrespond
@@ -433,13 +432,13 @@ Here is a list of related documentation: