Archive 1.x:CRUD: Read/1.1

From OSF Wiki
Jump to: navigation, search
CRUD: Read endpoint version:
1.1
2
3

The CRUD: Read Web service is used to get the description of a target instance record indexed in a dataset belonging to a WSF (Web Services Framework).

Developers communicate with the CRUD: Read Web service using the HTTP GET method. You may request one of the following mime types: (1) text/xml, (2) application/rdf+xml or (3) application/rdf+n3. The content returned by the Web service will be serialized using the mime type requested and the data returned will depend on the parameters selected.

Version

This documentation page is used for the version 1.1 of this endpoint. Check at the top of this page to see the documentation pages for the other versions of this endpoint.

Usage

This Web service is intended to be used by any user that wants to get the description of an instance record.

Web Service Endpoint Information

This section describes all you 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.

Needed registered CRUD permission:
  • 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.

HTTP Method:
  • GET
  • POST

Possible "Accept:" HTTP header field value:

  • text/xml (structXML)
  • application/json (structJSON)
  • application/rdf+xml (RDF+XML)
  • application/rdf+n3 (N3/Turtle)
  • application/iron+json (irJSON)
  • application/iron+csv (commON)

URI:

  • http://[...]/ws/crud/read/ ?uri=param1&dataset=param2&include_linksback=param3&include_reification=param4&include_attributes_list=param5&registered_ip=param6

URI dynamic parameters description:

Note: All parameters have to be URL-encoded

  • param1. URI of the instance record. Multiple URIs can be added to this parameter by splitting them with ";". That way, you can get more than one record description by query.
  • param2. (optional) URI of the dataset where the instance record is indexed. If this parameter is omitted (empty), the web service will query all the datasets of the system, that can be read by the requester, to try to find a definition for this record URI. Multiple URIs can be added to this parameter by splitting them with ";".
  • param3. One of:
    • True — Means that the reference to the other instance records referring to the target instance record will be added in the resultset
    • False (default) — No links-back will be added
  • param4. Include possible reification statements for a record. One of:
    • True
    • False (default)
  • param5. (optional) A list of attribute URIs to include into the resultset. Sometime, you may be dealing with datasets where the description of the entities are composed of thousands of attributes/values. Since the Crud: Read web service endpoint returns the complete entities descriptions in its resultsets, this parameter enables you to restrict the attribute/values you want included in the resultset which considerably reduce the size of the resultset to transmit and manipulate. Multiple attribute URIs can be added to this parameter by splitting them with ";".
  • param6. Target IP address registered in the WSF

Example of Returned XML Document

This is an example of the XML document returned by this Web service endpoint for a given dataset URI.

This example returns the description of a dataset registered to a WSF.

Query:

"Accept:" HTTP header field value:

  • text/xml

Result:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE resultset PUBLIC "-//Structured Dynamics LLC//Crud Read DTD 0.1//EN" "http://[...]/ws/dtd/crud/crudRead.dtd">
  3. <resultset>
  4.    <prefix entity="rdf" uri="http://www.w3.org/1999/02/ 22-rdf-syntax-ns#"/>
  5.    <subject type="http://xmlns.com/foaf/0.1/Person" uri= "http://bknetwork.org/drupal/bkn/datasets/227/resource/Bob">
  6.       <predicate type="http://xmlns.com/foaf/0.1/name">
  7.          <object type="rdfs:Literal">Bob</object>
  8.       </predicate>
  9.       <predicate type="http://xmlns.com/foaf/0.1/family_name">
  10.          <object type="rdfs:Literal">Gratton</object>
  11.       </predicate>
  12.    </subject>
  13. </resultset>

Descriptions of the Types of XML Elements

The elements used to describe an instance record depend on the vocabularies (ontologies) used to describe the instance record in RDF when it was first indexed in the system. Usually more information can be found on the Web for each property and class by creating the full identifier of a property or a class by using the prefix(es) of the XML document.

Example of Returned RDF/XML Document

Here is an example of a RDF/XML document returned by this Web service endpoint for a given URI.

Query<:

"Accept:" HTTP header field value:

  • application/rdf+xml

Result:

  1. <?xml version="1.0"?>
  2. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ns0="http://xmlns.com/foaf/0.1/">
  3.    <ns0:Person rdf:about="http://bknetwork.org/drupal/bkn/ datasets/227/resource/Bob">
  4.       <ns0:name>Bob</ns0:name>
  5.       <ns0:family_name>Gratton</ns0:family_name>
  6.    </ns0:Person>
  7. </rdf:RDF>

Example of Returned RDF/N3 Document

Here is an example of a RDF/N3 document returned by this Web service endpoint for a given URI.

Query:

"Accept:" HTTP header field value:

  • application/rdf+n3

Result:

  1. @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  2. <http://bknetwork.org/drupal/bkn/datasets/227/resource/Bob> a <http://xmlns.com/foaf/0.1/Person> ;
  3. <http://xmlns.com/foaf/0.1/name> """Bob""" ;
  4. <http://xmlns.com/foaf/0.1/family_name> """Gratton""" .

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: This resource is not existing
    • Message description: No URI specified for any resource
    • 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