2610
Comment:
|
2542
updated links to python documentation, removed empty Discussion section
|
Deletions are marked like this. | Additions are marked like this. |
Line 93: | Line 93: |
For some reason, these capabilities do not seem to be described in [http://www.python.org/doc/current/lib/module-xmlrpclib.html the xmlrpclib documentation.] | For some reason, these capabilities do not seem to be described in [http://docs.python.org/lib/module-xmlrpclib.html the xmlrpclib documentation.] |
Line 97: | Line 97: |
* [http://www.python.org/doc/current/lib/xmlrpc-client-example.html official xmlrpclib example] * [http://www.python.org/doc/current/lib/module-xmlrpclib.html xmlrpclib documentation] |
* [http://docs.python.org/lib/xmlrpc-client-example.html official xmlrpclib example] * [http://docs.python.org/lib/module-xmlrpclib.html xmlrpclib documentation] |
Line 101: | Line 101: |
= Discussion = (none yet!) |
XML-RPC
XML-RPC is a neat way to send messages across the Internet.
The neat thing about XML-RPC is that it transports native data structures- you can ship off lists, strings, dictionaries, and numbers.
You can [wiki:Wiki/XmlRpc read more about it over on C2,] or on [http://www.xmlrpc.com/ the XML-RPC home page.]
Sample Code
This code calls the PythonInfo wiki, and receives the TitleIndex as a list.
Message Format
If you can communicate strings, you can do XML-RPC. You could even do it by e-mail!
Here's how to make your string:
...resulting in the following call_string value:
<?xml version='1.0'?> <methodCall> <methodName>foo</methodName> <params> <param> <value><string>robot</string></value> </param> <param> <value><struct> <member> <name>dict</name> <value><int>2</int></value> </member> <member> <name>some</name> <value><int>1</int></value> </member> </struct></value> </param> <param> <value><array><data> <value><int>1</int></value> <value><int>2</int></value> <value><int>3</int></value> <value><int>4</int></value> <value><int>5</int></value> </data></array></value> </param> </params> </methodCall>
...which can then be turned back into Python data:
1 call_data = xmlrpclib.loads( call_string )
...which then builds:
(('robot', {'some': 1, 'dict': 2}, [1, 2, 3, 4, 5]), u'foo')
That is, the first item is the arguments tuple, and the second item is the name of the function.
For some reason, these capabilities do not seem to be described in [http://docs.python.org/lib/module-xmlrpclib.html the xmlrpclib documentation.]
See Also
[http://docs.python.org/lib/xmlrpc-client-example.html official xmlrpclib example]
[http://docs.python.org/lib/module-xmlrpclib.html xmlrpclib documentation]
[http://www.onlamp.com/pub/a/python/2001/01/17/xmlrpcserver.html XML-RPC: It Works Both Ways (onlamp.com)]
DocXmlRpcServer - class to help make an XML-RPC server