[Download] | [Documentation Home] | [Release Note]

Exposing Relational Data in RDF Format

Introduction


WSO2 Data Services Server supports to expose relational data in RDF (Resource Description Framework)format as a service. This guide will demonstrate how CSV data source can be exposed as a RDF resource. To create CSV datasource please refer Create CSV DataServices User Guide.

Step 1: Create a Query


In order to expose relational data in RDF format you need to configure the query accordingly. Therefore, we will add a new query to our CSVDataService.

To Add Query, click on "Add New Query" under query section, and fill query details as shown below.

Since our output is RDF result set, we need to specify our output type as RDF. RDF Base URI is the format of rdf:about URI which uniquely identifies each resource. We will give RDF base URI as http://www.product/cd/{1}; this takes the CSV column 1(which is the ProductCode) value for each row and replaces it for the RDF about attribute inside rdf:Description element.

RDF Base URI :- http://www.product/cd/{1}

Row namespace :- http://www.product/cd#


DS

Figure 1: Add Query


Step 2: Generate the Response


To generate the response in RDF format click on "Add New Output Mappings" button. There are two mapping types in RDF Output mapping. 1) as a element, 2) as a resource. When mapping an element as a resource, you need to give the resource URI along with the column name which needs to be mapped in curly brackets as shown below. This way we can link two RDF resources together and create a relationship between each other.


DS

Figure 2: Configure Output Mappings


Once you create the output mappings you can can go back to main configuration and save your RDF query.


DS

Figure 3: Configured RDF Query


Step 3: Add Resource


To create the RDF resource you need to map your RDF query as a resource in WSO2 Data Services. In order to create a resource you need to go to resource section and click "Add New Resource". Give a suitable name and a description for your resource and give the resource method as "Get" and select the the rdfQuery created in the previous step as the Query ID. Once we create the resource we can access our RDF resource via a rest call. Click "Finish" to deploy the Data Service.


DS

Figure 4: Add New Resource


Step 4: Invoke the service


You can invoke the created web service as a rest call by accessing the following URL http://10.100.0.170:9763/services/CSVSampleService.HTTPEndpoint/products


DS

Figure 5: Invoke service


Step 5: Validate the RDF Resource


You can validate generated RDF response by using an Online validator


DS

Figure 6: Validated Results