From sven at beta9.be Thu Jul 8 19:49:17 2004 From: sven at beta9.be (Sven Van Caekenberghe) Date: Thu, 8 Jul 2004 21:49:17 +0200 Subject: [s-xml-rpc-devel] Defining remote functions In-Reply-To: <10396097-C08B-11D8-8C76-000A959C96CC@free.fr> References: <10396097-C08B-11D8-8C76-000A959C96CC@free.fr> Message-ID: On 17 Jun 2004, at 20:20, Fr?d?ric Brunel wrote: > Hi, > > By googling the Web for an XML-RPC implementation in Common Lisp, I > found S-XML-RPC and other one for Corman Lisp. I'm glad that > S-XML-RPC is now part of Common-Lisp.net. > > By the way, looking at the Corman Lisp API for XML-RPC, I found > interesting that it have the ability to define a standard function > embedding an XML-RPC call. How about implementing this kind of thing > in S-XML-RPC? I wrote the following lines of code: > > (defmacro define-xmlrpc-method (name args &key url method) > `(defun ,name ,args > (xml-rpc-call (encode-xml-rpc-call ,method , at args) > :url ,(puri:uri-path url) > :host ,(puri:uri-host url) > :port ,(cond ((puri:uri-port url)) (t 80))))) > > (define-xmlrpc-method get-state-name (state) > :url #u"http://betty.userland.com/RPC2" > :method "examples.getStateName") > > (define-xmlrpc-method get-time () > :url #u"http://time.xmlrpc.com/RPC2" > :method "currentTime.getCurrentTime") > > ? (get-state-name 41) > "South Dakota" > > ? (get-time) > # > > I rely on the great PURI package to parse URL. Quite straightforward. > Of course, we should also wrap and unwrap some type convertions not > to see anything about the XML-RPC types. I guess the function should > also accept HASHTABLEs to be converted in XML-RPC structs. > > What do you think? > > -- > Frederic Brunel > I added your code in a file called define-xmlrpc-method.lisp that is not part of the project itself (because of its dependency on puri), but more an extension like aserve.lisp Thanks for the contribution, Sven