Registry Manual REST API SPARQL SAWSDL BioMoby WSDL 1.1 Tutorial Contact Us

BioSWR supports SPARQL 1.1 protocol for services querying and semantic annotations management. The HTTP service endpoint which processes SPARQL queries is described in table 1.

URL in relation to:
HTTP Method: description:
/sparql/?query={query} GET Execute SPARQL 1.1 query over complete BioWSR OWL/RDF storage. The query parameter must be URL encoded
/sparql/ POST The request may be either QUERY or UPDATE operation.
When content is URL encoded (Content-Type: application/x-www-form-urlencoded), the operation is defined by the "query" or "update" form parameter.
When the content is posted directly, the operation is defined by the content type (Content-Type: application/sparql-query) or (Content-Type: application/sparql-update).
See SPARQL 1.1 Protocol for details.
Table 1. SPARQL endpoint

SPARQL protocol support makes it easy to query registered services Table 1..

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wsdl-rdf: <http://www.w3.org/ns/wsdl-rdf#>
SELECT ?label
WHERE {
  ?service rdf:type wsdl-rdf:Service .
  ?service rdfs:label ?label
}
Table 2. SPARQL query that gets names of all registered service

The query may be executed directly in any browser: http://.../BioSWR/rest/sparql/query=...

More sophisticated query may not only return the required service descriptions, but also their location into the BioSWR Registry (table 3).

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wsdl-rdf: <http://www.w3.org/ns/wsdl-rdf#>
PREFIX sawsdl: <http://www.w3.org/ns/sawsdl#>
PREFIX xs: <http://www.w3.org/2001/XMLSchema#>
DESCRIBE ?m
WHERE {
  ?s rdf:type wsdl-rdf:Service .
  ?s wsdl-rdf:implements ?i .
  ?i wsdl-rdf:interfaceOperation ?o .
  ?o wsdl-rdf:interfaceMessageReference ?m .
  ?m rdf:type wsdl-rdf:InputMessage .
  ?m sawsdl:modelReference "http://edamontology.org/data_1127"^^xs:string
}
Table 3. SPARQL query that gets RDF description for the service which input annotated as PDB identifier in EDAM ontology

http://.../BioSWR/rest/sparql/query=...

The resulted description contains a wsdli:wsdlLocation which points to the service descriptor location:
http://.../BioSWR/rest/service/5BC5BEC0AB7193D0E0488EA49DAFCDD2

Web interface also allows SPARQL queries usage to filter the services table. In this case the query must return a service description. The query that perform the same search as in previous example can be found in table 4.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wsdl-rdf: <http://www.w3.org/ns/wsdl-rdf#>
PREFIX sawsdl: <http://www.w3.org/ns/sawsdl#>
PREFIX xs: <http://www.w3.org/2001/XMLSchema#>
SELECT ?s WHERE {
  ?s rdf:type wsdl-rdf:Service .
  ?s wsdl-rdf:implements ?i .
  ?i wsdl-rdf:interfaceOperation ?o .
  ?o wsdl-rdf:interfaceMessageReference ?m .
  ?m rdf:type wsdl-rdf:InputMessage .
  ?m sawsdl:modelReference "http://edamontology.org/data_1127"^^xs:string
}
Table 4. SPARQL query to select the services which input annotated as PDB identifier in EDAM ontology

SPARQL update may be used to manage semantic annotations. BioSWR supports sawsdl:modelReference, rdfs:comment, rdfs:seeAlso and rdfs:isDefinedBy) annotations. All other annotations will be ignored.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX sawsdl: <http://www.w3.org/ns/sawsdl#>
INSERT DATA {
  <urn:lsid:inb.bsc.es#wsdl.interface(describePDB)> sawsdl:modelReference 'http://example.com'
}
Table 5. SPARQL update query to annotate describePDB service

SPARQL 1.1 endpoint is easy to use from the client point of view:

final String SELECT =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" +
"PREFIX wsdl-rdf: <http://www.w3.org/ns/wsdl-rdf#>" +
"SELECT ?label WHERE {" +
"?service rdf:type wsdl-rdf:Service . " +
"?service rdfs:label ?label}";

URI uri = new URI("http", null, "inb.bsc.es", 80, "/BioSWR/rest/sparql/", "query=" + SELECT, null);
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();

InputStream input = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
try {
  String ln;
  while ((ln = reader.readLine()) != null) {
    System.out.println(ln);
  }
} catch(Exception ex) {
  ex.printStackTrace();
} finally {
  input.close();
}
Table 6. Java code for SPARQL query execution example

The output of the query will contain an XML with names of all registered services:

<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
  <head>
    <variable name='label'/>
  </head>
  <results>
    <result>
      <binding name='label'>
        <literal datatype='http://www.w3.org/2001/XMLSchema#string'>runMDFromGROMACS_MD_Structure</literal>
      </binding>
    </result>
    ...
  </results>
</sparql>
Table 7. SPARQL SELECT query (Table 2) result