I have a question:
I have read on the Web that SPARQL endpoint is a Web service that answers SPARQL queries for some dataset.
I have read also that I can realize a Web Service which has a method that queries the data on triple store and so I have a SPARQL endpoint. It's right?
I'm using a Jena TDB Triple Store and my question is:
How I can realize a SPARQL Endpoint public (like dbpedia.org/sparql) if I use only Web Service?
I'm using Netbeans with Glassfish4.0 and this is my code:
@WebService(serviceName = "query_ws")
@Stateless()
public class query_ws {
String directory = "C:\\jena\\tdb";
@WebMethod(operationName = "query")
public String query(@WebParam(name = "strquery") String strquery){
String results = queryTDB(strquery, directory);
return results;
}
public String queryTDB(String queryStr, String directory) {
Dataset dataset = TDBFactory.createDataset(directory);
Query query = QueryFactory.create(queryStr);
QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
qexec.getContext().set(TDB.symUnionDefaultGraph, true);
ResultSet results = qexec.execSelect();
String strings = ResultSetFormatter.asText(results);
qexec.close();
return strings;
}
Apache Jena Fuseki is the Jena project's SPARQL server.
You can use that as a standalone server, or you can use it as a library of servlets, or you can extract the code you want from the source.