|start | find | index | login or register | edit|
rebXR Users Guide
by earl, 4751 days agoThis is the official rebXR Users Guide. Downloads and more generic information can be found here.
Please note that this Users Guide already reflects the status of the upcoming rebXR release currently available as experimental version.
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. It's designed to be as simple as possible, while allowing complex data structures to be transmitted, processed and returned." - http://www.xmlrpc.com
What is REBOL?
REBOL is a quite revolutionary scripting language, primarily architected by Carl Sassenrath of Amiga fame.
Carl Sassenrath about REBOL: "A friend of mine says it's like the movie 'Matrix' where you are offered either the red pill or the blue pill. Most programmers stick with the blue pill. The folks who take the REBOL red pill wake up and can never go back
"However, REBOL was designed from a meta-circular view of language semantics. That is, REBOL is what you need it to be. It morphs to provide the maximal expressive power for any problem."
Read more about REBOL on http://www.rebol.com/
The solid flavor of rebXR would not have been possible without Gavin McKenzie's brilliant XML libraries for REBOL. Asynchronous networking support is achieved with the async:// library written by Gabriele Santilli, Maarten Koopmans and Romano Paolo Tenca.
For your convenience, all external libraries necessary to use rebXR is bundled in a single package. By running the
Fortunately REBOL features many, many builtin types, so mapping those few XML-RPC types to REBOL types is quite straightforward:
The first element in the method block is supposed to be the remote procedure name, all other elements are supposed to be parameters. Be careful and do not forget to 'reduce the method-block appropriately! Some examples:
If you want to use asynchronous networking, you have to provide a callback function which will be invoked when the method call completed and the results were returned. This callback function must accept exactly one parameter (the result) and an
If the method call completed successfully, the callback will be invoked without the /error refinement, the argument will be the result of the method call. If an error occured, the callback will be invoked with the /error refinement and the argument will be the disarmed error object. An example:
rebXR currently supports CGI-based and standalone server. Using them is trivial ;) Simply write down the functions you'd like to provide. Load the rebXR libs and the server lib for the server type you plan to use; the %rebxr.r bundle created by %make-lib.r by default includes the standalone server library. Finally, add one line at the end of the file:
If you are running as CGI:
If using a standalone async:// server:
The methods-block specifies to which XML-RPC method calls this server should reply. For example:
would serve the two native REBOL functions add and subtract, both taking 2 parameters and doing what you would expect ;) (The example uses the standalone server.)
would also set up a default handler, which will be called whenever a method was requested which was not explicitly served as specified in the :methods-block. When the default handler returns none, the server will send a 'Method not supported' exception to the calling client. Otherwise it will send back the results as returned by the default handler. (This example uses the CGI-based server.)
The default-handler gets the original request passed in as 'orig-call. This is a block, with the method to be invoked as first element followed by its original arguments.
A nice trick (although missing some error handling and obviously a lot of security) to expose all REBOL/Core functions to XML-RPC invocation:
Chris Langreiter for mental support and cheering.
Graham Chiu for extensive bugtesting and worthy feedback.
Maarten Koopmans greatly helped with the async:// support.
Gavin McKenzie for the great XML libs!
Dave Winer for the nice XML-RPC work.
-- Andreas Bolka
1 active user
|earl.strain.at • esa3 • online for 6045 days • c'est un vanilla site|