Using xmlrpc-client.lsp...

Started by oofoe, January 09, 2016, 05:17:43 AM

Previous topic - Next topic

oofoe

Hi!



I ran into a little problem when using %xmlrpc-client.lsp with our python/django XMLRPC server at work. It has a very strict interpretation of how many arguments it will accept for certain functions, like system.listMethods, so the default request with the single dummy argument won't work.



I wound up adding something like this to xmlrpc-client.lsp:

(define (format-request method)
  "( method /arg.../ -- XML) Compose XML request."

  (let ((xml (format
     "<?xml version="1.0"?><methodCall><methodName>%s</methodName><params>"
     method)))
    (dolist (value (args))
      (push (format "<param><value>%s</value></param>" value) xml -1))
    (push "</params></methodCall>n" xml -1)))


Then changing system.listMethods to:

(define (system.listMethods url)
    (execute url (format-request "system.listMethods")))


Technically, format-request should also determine the type of the argument values (and encode lists and dictionaries correctly), but if you're only using string arguments, it should suffice.



Maybe someone has a better format-request they could share? ; - )
Testing can show the presence of bugs, but not their absence.

Lutz

#1
Thanks Oofoe, additions added to the module:



http://www.newlisp.org/code/modules/xmlrpc-client.lsp.html">http://www.newlisp.org/code/modules/xml ... t.lsp.html">http://www.newlisp.org/code/modules/xmlrpc-client.lsp.html

abaddon1234

#2
Thanks for the info

https://www.gclubtg.com/">ทางเข้า gclub