Database Reference
In-Depth Information
You can execute the ProxyStoreApp example like so:
java -jar xmlrpc-proxy-client-store/target/
xmlrpc-proxy-client-store-1.0-example.jar
This shows the available arguments for using the ProxyStoreApp.
A complete example of using the application might look like the following, which
would upload the file /tmp/large.xml to the collection /db/my-new-collection in eXist:
java -jar xmlrpc-proxy-client-store/target/
xmlrpc-proxy-client-store-1.0-example.jar localhost 8080
/tmp/large.xml application/xml
/db/my-new-collection admin
Using the XML-RPC client API from Python
As XML-RPC is such a prevalent and well-supported protocol, we felt that a simple
example for a non-Java programming language might be beneficial to those of you
who are not familiar with Java. We have created a direct port of the dynamic proxy
XML-RPC example into Python, the source code of which is included in the file
chapters/integration/xmlrpc-client/StoreApp.py of the book-code Git repository.
Python has a built-in XML-RPC library called xmlrpclib , which is very simple to use
(see Example 13-11 ). It works on the principle of dynamic proxies, but as Python is
more relaxed in its compilation here than Java, you will not see compile-time errors if
you try to call an RPC method that does not exist. This is because Python has no
knowledge at compile time of the RPC methods made available by eXist, as you have
not needed to provide it an interface like you do with Java. The version of Python
used was 2.7.2.
Example 13-11. Python dynamic proxy XML-RPC client
import xmlrpclib
rpc = xmlrpclib . ServerProxy ( "http://localhost:8080/exist/xmlrpc" )
result = rpc . existsAndCanOpenCollection ( "/db" )
print "Collection exists and we can open it: %s " % result
Python XML-RPC proxy store example. The source code of a small example of using
XML-RPC from Python to store a file is included in the folder chapters/integration/
xmlrpc-client of the book-code Git repository (see “Getting the Source Code” on page
15 ).
The Python store example is externally exactly the same as the Java dynamic proxy
example, and can be found in the StoreApp.py file. You can execute the Python Store‐
App example like so:
Search WWH ::




Custom Search