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

Step-by-step guide on creating data Services using CSV file

Introduction


WSO2 Data Services Server provides the capability of exposing data from a CSV (Comma seperated Text file) file as a service over the web. This guide will use a csv file which has hosted by USGS (http://www.usgs.gov). USGS provides reliable scientific information to describe & understand the Earth. As part of its services, USGS hosts latest earthquake information in comma separated (CSV) text files online.

This guide explains how to create a web service that will expose earthe quake information - the SOA way, using WSO2 Data Services Server.

The guide will be using the CSV file available @ http://earthquake.usgs.gov/eqcenter/catalogs/eqs1day-M1.txt and expose its 9 columns conforming to following xml format.



DS

Figure 1: Sample csv 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 EarthquakeInfoService and click on "Next".



DS

Figure 2: Create data service



Step 2: Enter details about your CSV file


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 CSV file which is in your local machine.



DS

Figure 2: Configure csv data source

Column Separator Values

Click on "Save" once you have entered the details about the data source. Created data source will be listed as below. Click on "Next" to add queries.

DS Figure 3: View data source

Step 3: Configure how the response should look like

You can enter the details of the query to create the structure of the response you wish.

Enter a name to the query, and select the data source name from the drop down, which is created in previous step. Enter a name for Grouped By Element and Row Name. You can also give a namespace if you wish. Click on "Add Output Mapping" button to create how the output should look like. Once you have entered the output mapping details click on "Main Configuration" and lick on "Save" button.



DS

Figure 4: Create new querry



Created query will be listed as follows. Click on "Next" to create the operation.



DS

Figure 5: View operation



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".



DS

Figure 6: Add operation



Added operation will list as follows. Once you click on "Finish" your data service will be created and deployed.



DS

Figure 7: View operation



Step 5: Service deployed


You can see the deployed service by clicking on "List" under Manage/Services left menu. Deployed EarthquakeInfoService service will be list as follows.



DS

Figure 8: Deployed services



Click on the "EarthquakeInfoService". It will direct to the Service Dashboard (EarthquakeInfoService). You can click on "Edit Data Service(XML Edit)" and view the created data service as a xml.



DS

Figure 9: Edit data service



Step 6: Try your service


Click on "Try It" link to invoke the servie.



DS

Figure 10: Invoke service using Try-it



Browser URL - using SOAP HTTP binding

http://localhost:9762/services/EarthquakeInfoService/getEarthquakesForPastDay

https://10.100.1.145:9443/services/EarthquakeInfoService/getEarthquakesForPastDay



DS

Figure 11: Invoke services using SOAP HTTP binding