SPARQL
From DocWiki
The SPARQL Web service is used to send custom SPARQL queries against the structWSF data structure. This is a general purpose querying Web service.
Developers communicate with the SPARQL Web service using the HTTP POST method. You may request one of the following mime types: (1) text/xml, (2) application/rdf+xml, (3) application/rdf+n3, (4) application/sparql-results+xml, (5) application/sparql-results+json or (6) application/json. The content returned by the Web service is serialized using the mime type requested and the data returned depends on the parameters selected.
Contents |
Usage
This Web service is intended to be used by content management systems, developers or administrators to manage access to WSF (Web Service Framework) resources (users, datasets, Web services endpoints).
If the requested content type sent to the SPARQL web service endpoint is not "application/sparql-results+xml" nor "application/sparql-results+json", then it means that the web service is used to record complete record descriptions based on a SPARQL search pattern. Only the two SPARQL resultsets serialization formats will return the except SPARQL resultsets.
If the SPARQL endpoint is used to get complete records description based on SPARQL patterns, then the three variables (1) ?s, (2) ?p and (3) ?o variables have to be bound in the SPARQL query, otherwise no result will be returned. Here is an example of a query that match all the records that are muni:County and that have an iron:prefLabel. However, as you can notice in the query, the three variable ?s ?p &o are bound so that the SPARQL endpoint return the complete record description for the requested content type "application/rdf+xml":
SELECT ?s ?p ?o WHERE { ?s a <http://purl.org/ontology/muni#County> ; <http://purl.org/ontology/iron#prefLabel> ?name ; ?p ?o . }
Web Service Endpoint Information
This section describes the permissions you need in the WSF (Web Service Framework) to send a query to this Web service endpoint, and it describes how to access it.
To access this Web service endpoint you need the proper CRUD (Create, Read, Update and Delete) permissions on a specific graph (dataset) of the WSF. Without the proper permissions on this graph you won't be able to send any queries to the endpoint.
- Create: False
- Read: True
- Update: False
- Delete: False
As shown on the graph URI:
- URI of the dataset where the instance record is indexed
Here is the information needed to communicate with this Web service's endpoint. Descriptions of the parameters are included below.
Note: if a parameter has a default value, the requester can omit it and the default value will be used. Also, some baseline Web services may not offer other values than the default.
- POST
Possible "Accept:" HTTP header field value:
- text/xml (DTD validating the returned content)
- application/json
- application/rdf+xml
- application/rdf+n3
- application/sparql-results+xml
- application/sparql-results+json
URI:
- http://[...]/ws/sparql/ ?query=param1&dataset=param2&limit=param3&offset=param4®istered_ip=param5
URI dynamic parameters description:
Note: All parameters have to be URL-encoded
- param1. The SPARQL query to send to the Web service endpoint
- param2. URI referring to a target dataset to query.
- param3. Limit of the number of results to return in the resultset(max 2000)
- param4. Offset of the "sub-resultset" from the total resultset of the query
- param5.Target IP address registered in the WSF. Needed when the IP of the requester is not the one of the one making the request to the endpoint. Otherwise this parameter as to be omitted.
Content Returned
The content returned by the Web service endpoint depends on the "Accept:" parameter sent by the requester. The user can request one of the five supported mime types. The converted content from the input document will be returned by using the requested serialization format.
HTTP Status Codes
Here are the possible HTTP status (error) codes returned by this Web service endpoint.
On error code and the specific error, a different message description can be issued (meaning a different error has been returned).
- Code:200
- Message:OK
- Code:400
- Message:Bad Request
- Message description:No query specified for this request
- Message description:No dataset specified for this request
- Message description:No data to import
- Message description:No requester IP available
- Message description: No Web service URI available
- Message description:Target Web service XYZ not registered to this Web Services Framework
- Message description:No access defined for this requester IP XYZ, dataset (XYZ) and Web service (XYZ)
- Message description:The target Web service (XYZ) needs create access and the requested user (XYZ) doesn't have this access for that dataset (XYZ)
- Message description:The target Web service (XYZ) needs read access and the requested user (XYZ) doesn't have this access for that dataset (XYZ)
- Message description:The target Web service (XYZ) needs update access and the requested user (XYZ) doesn't have this access for that dataset (XYZ)
- Message description:The target Web service (XYZ) needs delete access and the requested user (XYZ) doesn't have this access for that dataset (XYZ)
- Code:406
- Message:Not Acceptable
- Message description:Unacceptable mime type requested
- Code:500
- Message:Internal Error