Common Lisp Package: S-XML-RPC

An implementation of the standard XML-RPC protocol for both client and server

README:

FUNCTION

Public

CALL-XML-RPC-SERVER (SERVER-KEYWORDS NAME &REST ARGS)

Encode and execute an XML-RPC call with name and args, using the list of server-keywords

ENCODE-XML-RPC-CALL (NAME &REST ARGS)

Encode an XML-RPC call with name and args as an XML string

EXECUTE-XML-RPC-CALL (METHOD-NAME &REST ARGUMENTS)

Execute method METHOD-NAME on ARGUMENTS, or raise an error if no such method exists in *XML-RPC-PACKAGE*

GET-XML-RPC-STRUCT-MEMBER (STRUCT MEMBER)

Get the value of a specific member of an XML-RPC-STRUCT

SETFGET-XML-RPC-STRUCT-MEMBER (VALUE STRUCT MEMBER)

Set the value of a specific member of an XML-RPC-STRUCT

START-XML-RPC-SERVER (&KEY (PORT *XML-RPC-PORT*) (URL *XML-RPC-URL*) (AGENT *XML-RPC-AGENT*))

Start an XML-RPC server in a separate process

STOP-SERVER (NAME)

Kill a server process by name (as started by start-standard-server)

system.getCapabilities

Get a list of supported capabilities; see http://groups.yahoo.com/group/xml-rpc/message/2897 for the specification.

system.listMethods

List the methods that are available on this server.

system.methodHelp (METHOD-NAME)

Returns the function documentation for the given method.

system.methodSignature (METHOD-NAME)

Dummy system.methodSignature implementation. There's no way to get (and no concept of) required argument types in Lisp, so this function always returns nil or errors.

system.multicall (CALLS)

Implement system.multicall; see http://www.xmlrpc.com/discuss/msgReader$1208 for the specification.

XML-RPC-CALL (ENCODED &KEY (URL *XML-RPC-URL*) (AGENT *XML-RPC-AGENT*) (HOST *XML-RPC-HOST*) (PORT *XML-RPC-PORT*) (AUTHORIZATION *XML-RPC-AUTHORIZATION*) (PROXY-HOST *XML-RPC-PROXY-HOST*) (PROXY-PORT *XML-RPC-PROXY-PORT*))

Execute an already encoded XML-RPC call and return the decoded result

XML-RPC-STRUCT (&REST ARGS)

Create a new XML-RPC-STRUCT from the arguments: alternating member names and values

XML-RPC-STRUCT-ALIST (INSTANCE)

Return the alist of member names and values from an XML-RPC struct

XML-RPC-STRUCT-EQUAL (STRUCT1 STRUCT2)

Compare two XML-RPC-STRUCTs for equality

XML-RPC-STRUCT-P (OBJECT)

Return T when the argument is an XML-RPC struct

XML-RPC-TIME (&OPTIONAL (UNIVERSAL-TIME (GET-UNIVERSAL-TIME)))

Create a new XML-RPC-TIME struct with the universal time specified, defaulting to now

XML-RPC-TIME-P (OBJECT)

Return T when the argument is an XML-RPC time

XML-RPC-TIME-UNIVERSAL-TIME (INSTANCE)

Return the universal time from an XML-RPC time

Undocumented

SETFXML-RPC-STRUCT-ALIST (NEW-VALUE INSTANCE)

SETFXML-RPC-TIME-UNIVERSAL-TIME (NEW-VALUE INSTANCE)

Private

DESCRIBE-SERVER (&KEY (HOST *XML-RPC-HOST*) (PORT *XML-RPC-PORT*) (URL *XML-RPC-URL*))

Tries to describe a remote server using system.* methods

FIND-XML-RPC-METHOD (METHOD-NAME)

Looks for a method with the given name in *xml-rpc-package*, except that colons in the name get converted to hyphens.

HANDLE-XML-RPC-CALL (IN ID)

Handle an actual call, reading XML from in and returning the XML-encoded result.

ISO8601->UNIVERSAL-TIME (STRING)

Convert string in the XML-RPC variant of ISO8601 to a Common Lisp universal time

RUN-PROCESS (NAME FUNCTION &REST ARGUMENTS)

Create and run a new process with name, executing function on arguments

START-STANDARD-SERVER (&KEY PORT NAME CONNECTION-HANDLER)

Start a server process with name, listening on port, delegating to connection-handler with stream as argument

UNIVERSAL-TIME->ISO8601 (TIME &OPTIONAL (STREAM NIL))

Convert a Common Lisp universal time to a string in the XML-RPC variant of ISO8601

XML-LITERAL (CONTENT)

Create a new XML-LITERAL struct with the specified content.

XML-LITERAL-CONTENT (INSTANCE)

Return the content of a literal xml string

XML-LITERAL-P (OBJECT)

Return T when the argument is an unescaped xml string

XML-RPC-IMPLEMENTATION-VERSION

Identify ourselves

XML-RPC-SERVER-CONNECTION-HANDLER (CONNECTION ID AGENT URL)

Handle an incoming connection, doing both all HTTP and XML-RPC stuff

Undocumented

COPY-XML-LITERAL (INSTANCE)

COPY-XML-RPC-STRUCT (INSTANCE)

COPY-XML-RPC-TIME (INSTANCE)

DEBUG-STREAM (IN)

DECODE-XML-RPC (STREAM)

DECODE-XML-RPC-FINISH-ELEMENT (NAME ATTRIBUTES PARENT-SEED SEED)

DECODE-XML-RPC-NEW-ELEMENT (NAME ATTRIBUTES SEED)

DECODE-XML-RPC-TEXT (STRING SEED)

DO-ONE-MULTICALL (CALL-STRUCT)

ENCODE-XML-RPC-ARGS (ARGS STREAM)

ENCODE-XML-RPC-ARRAY (SEQUENCE STREAM)

ENCODE-XML-RPC-FAULT (FAULT-STRING &OPTIONAL (FAULT-CODE 0))

ENCODE-XML-RPC-FAULT-VALUE (FAULT-STRING &OPTIONAL (FAULT-CODE 0))

ENCODE-XML-RPC-RESULT (VALUE)

ENCODE-XML-RPC-STRUCT (STRUCT STREAM)

ENCODE-XML-RPC-VALUE (ARG STREAM)

FORMAT-DEBUG (&REST ARGS)

FORMAT-HEADER (STREAM HEADERS)

MAKE-XML-LITERAL (&KEY ((CONTENT DUM197) NIL))

MAKE-XML-RPC-STRUCT (&KEY ((ALIST DUM267) NIL))

MAKE-XML-RPC-TIME (&KEY ((UNIVERSAL-TIME DUM91) NIL))

TOKENS (STRING &KEY (START 0) (SEPARATORS (LIST )))

VALID-XML-RPC-METHOD-NAME-P (METHOD-NAME)

SETFXML-LITERAL-CONTENT (NEW-VALUE INSTANCE)

MACRO

Private

WITH-OPEN-SOCKET-STREAM ((VAR HOST PORT) &BODY BODY)

Execute body with a bidirectional socket stream opened to host:port

GENERIC-FUNCTION

Public

XML-RPC-ERROR-DATA (CONDITION)

Get the data from an XML-RPC error

XML-RPC-ERROR-PLACE (CONDITION)

Get the place from an XML-RPC error

XML-RPC-FAULT-CODE (CONDITION)

Get the code from an XML-RPC fault

XML-RPC-FAULT-STRING (CONDITION)

Get the string from an XML-RPC fault

VARIABLE

Public

*XML-RPC-AGENT*

String specifying the default XML-RPC agent to include in server responses

*XML-RPC-AUTHORIZATION*

When not null, a string to be used as Authorization header

*XML-RPC-CALL-HOOK*

A function to execute the xml-rpc call and return the result, accepting a method-name string and a optional argument list

*XML-RPC-DEBUG*

When T the XML-RPC client and server part will be more verbose about their protocol

*XML-RPC-DEBUG-STREAM*

When not nil it specifies where debugging output should be written to

*XML-RPC-HOST*

String naming the default XML-RPC host to use

*XML-RPC-PACKAGE*

Package for XML-RPC callable functions

*XML-RPC-PORT*

Integer specifying the default XML-RPC port to use

*XML-RPC-PROXY-HOST*

When not null, a string naming the XML-RPC proxy host to use

*XML-RPC-PROXY-PORT*

When not null, an integer specifying the XML-RPC proxy port to use

*XML-RPC-URL*

String specifying the default XML-RPC URL to use

Private

*COUNTER*

Unique ID for incoming connections

Undocumented

*SERVER-PROCESSES*

+CRLF+

+XML-RPC-METHOD-CHARACTERS+

CLASS

Public

XML-RPC-STRUCT (&REST ARGS)

An XML-RPC-STRUCT is an associative map of member names and values

XML-RPC-TIME (&OPTIONAL (UNIVERSAL-TIME (GET-UNIVERSAL-TIME)))

A wrapper around a Common Lisp universal time to be interpreted as an XML-RPC-TIME

Private

XML-LITERAL (CONTENT)

A wrapper around a Common Lisp string that will be sent over the wire unescaped

CONDITION

Public

XML-RPC-CONDITION

Parent condition for all conditions thrown by the XML-RPC package

XML-RPC-ERROR

This condition is thrown when an XML-RPC protocol error occurs

XML-RPC-FAULT

This condition is thrown when the XML-RPC server returns a fault