There is a library of classes to access a remote Joseki server in the package
com.hp.hpl.jena.joseki
. There are classes to perform queries, both
at the protocol level and within the RDQL query framework of
Jena, and classes
to perform the non-query operations like "ping", "options" as well as modify remote
RDF graphs by adding and removing RDF graphs from remote models. For operations to succeed, the
remote server must allow such operations on the target model.
The protocol used for access remote RDF is a simple use of HTTP GET which returns the smallest subgraph that matches the query (i.e. it gives the same results as the query on the original graph). Other operations use HTTP POST.
The primary class is QueryEngineHTTP, which implements the standard Jena QueryExecution interface for variable bindings. Remote queries are executed in the same manner as local queries, except that a different query execution object is used.
The following code fragments show using the client API in Java. See the Jena javadoc for more detailed documentation on the general query classes and the Joseki javadoc for QueryEngineHTTP.
Query q = new Query(queryString) ; QueryExecution qe = new QueryEngineHTTP(q, modelURI) ; QueryResults results = qe.exec() ; for ( Iterator iter = results ; iter.hasNext() ; ) { ResultBinding rbind = (ResultBinding)iter.next() ; // Assuming the query has a variable called "x" ... Object obj = rbind.get("x") ; // obj will be a Jena object: resource, property or RDFNode. System.out.println("x = "+obj.toString() ; } results.close() ;
See the class HttpQuery.
See the javadoc for the package
com.hp.hpl.jena.joseki
.