This is meant to complement and continue from where Tom Dyson's Getting started with Xindice 1.1 left off. It also relates to HOWTO Xindice 1.1b and Cocoon 2.
This document is incomplete and in progress. Please let the author know of any problems and errors.
Here's a very brief outline of how to do Xindice 1.1 XML-RPC, with Java examples.
Java: XmlRpcClient xClient = new
XmlRpcClient("http://localhost:8080/Xindice"); xHashtable.put("collection", "/db"); xHashtable.put("message", "ListCollections"). xVector.addElement(xHashtable); Hashtable returnedHash = (Hashtable)
xClient.execute("run",xVector); Vector cols = (Vector) returnedHash.get("result"); Getting started with Xindice 1.1 details how to:
Databases will by default be located in:
$TOMCAT_HOME/web-apps/Xindice/WEB-INF/db
| org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java | Implements the XML:DB Collection interface using XML-RPC to Xindice: good example client code. |
| org/apache/xindice/server/rpc/RPCDefaultMessage.java | Defines static variables for common Xindice RPC message names, such as "result", "name", "collection", "document", etc. |
| org/apache/xindice/server/rpc/RPCMessageInterface.java | Defines "message" as the message parameter used to get, from the hashtable passed to the server's run method, the name of the command to be executed. |
These are some of the keys used for setting RPC command parameters into a hashtable to be read by the server.
| Name | Value |
|---|---|
| "collection" | path-to-collection |
| "compressed" | "true" if document is to be returned compressed as a
hashtable, "false" if it is to be returned as a String. However, don't
use this parameter at all to get document back as a String. |
| "message" | The command to be executed by the Xindice XML-RPC server |
| "name" | Name of resource, such as name of collection to be created. |
| "result" | Gets the result from the hashtable returned from the RPC call |
Command names are sent to the Xindice service by adding a hashtable
entry with keyword "message" and the name of the command. They invoke
Java classes of the same name, located in:
org/apache/xindice/server/rpc/messages/.
Parameters required by the command are added as entries to the hashtable. The table below lists some of the commands and their parameters.
| Name | Parameters |
|---|---|
| "CreateCollection" | "collection",collection-path
"name", name of new collection |
| "CreateIndexer" | "collection", collection-path
"configuration", configuration |
| "GetCollectionCount" | "collection",collection-path |
| "GetDocument" | "collection", collection-path
"name", document id |
| "GetDocumentCount" | "collection",collection-path |
| "InsertDocument" | "collection",collection-path
"name", document id "document", the xml document |
| "ListCollections" | "collection",collection-path |
| "ListDocuments" | "collection",collection-path |
| "ListIndexers" | "collection",collection-path |
| "Query" | "collection", collection-path "type", "XPath" or "XUpdate" "namespaces", new Hashtable() "query", the query |
| "RemoveCollection" | "collection",collection-path
"name", name of collection |
| "RemoveDocument" | "collection",collection-path
"name", document id Result on success is "yes" |
| "RemoveIndexer" | |
| "SetDocument" | "collection",collection-path
"name", document id "document", xml document |
| "Shutdown" | |
| "UpdateIndexer" | |