[Download]
| [Documentation Home] | [Release Note]
Step-by-Step Guide on Creating Data Services Using RDF Resource
Introduction
WSO2 Data Services Server supports to expose data in RDF(Resource
Description Framework) as a service. This guide will use an online
RDF resource hosted by NASA, to demonstrate RDF data extraction
feature supported by wso2 data services server. The guide will be
using the RDF data source available @
(
http://nasa.dataincubator.org/)
which contains all the aircraft information for the past years.

Figure 1: Sample RDF File
Step 1: Start by giving a name
Lets begin to create the data service by clicking on "Create"
link in left menu under Services/Add/Data Service. It requires to
enter a name to the Data service. Lets name it as AircraftInfoService
and click on "Next".

Figure 2: Create Data Service
Step 2: Enter details about your RDF data source
Second step is to enter details about the data source which we are
using to create the service. Not only from an online hosted file, you
can also use a RDF file which is in your local machine or the
registry.

Figure 2: Configure RDF Data Source
Step 3: Configure how the response should look like
To extract information you need to create a query along with the
structure of the response.
Give a name to the query, and select the data source name from the
drop down, which is created in previous step. Give the SPARQL query
to extract the specific aircraft information from the data source.
The following SPARQL query is used to extract aircraft information
PREFIX space: <http://purl.org/net/schemas/space/>
PREFIX relevance: <http://a9.com/-/opensearch/extensions/relevance/1.0/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?homepage ?name ?alternateName ?internationalDesignator ?mass ?score ?launch ?agency ?description
WHERE {
?craft foaf:homepage ?homepage.
?craft foaf:name ?name.
?craft space:alternateName ?alternateName.
?craft space:internationalDesignator ?internationalDesignator.
?craft space:mass ?mass.
?craft relevance:score ?score.
?craft space:launch ?launch.
?craft space:agency ?agency.
?craft dc:description ?description.
}
To give parameters to the query, input mapping section can be used.
Following query extract aircraft information according to the agency
therefore, we will take agency as an input parameter. Input
parameters can be added by clicking "Add Input Mappings"
and add the input mappings accordingly.
Enter a name for Grouped By Element and Row Name. You can also
give a name space if you wish. Click on Add Output Mappings to map
the response to output XML

Figure 3: Create New Query
Once you have entered the output mapping
details click on "Main Configuration" and click on "Save"
button.

Figure 4: Add Output Mappings
Created query will be listed as follows. Click on "Next"
to create the operation.

Figure 5: Created Query
Step 4: Create a web service operation
Enter a name for the operation and select the query from the drop
down list. Click on "Save".

Figure 6: Add operation
Once you click on "Finish" your data service will be
created and deployed.
Step 5: Service deployed
You can see the deployed service by clicking on "List"
under Manage/Services left menu. Deployed AircraftInfoService service
will be list as follows.

Figure 7: Deployed Services
Click on the "EarthquakeInfoService". It will direct to
the Service Dashboard (AircraftInfoService). You can click on "Edit
Data Service (XML Edit)" and view the created data service as a
XML.

Figure 9: Edit data service
Step 6: Try your service
Click on "Try It" link to invoke the service.

Figure 10: Invoke service using Try-it