Using CSV files is an easy and common way of storing simple tabular data. This sample demonstrates the usage of a CSV file as a data source for data service in WSO2 DSS.
About the sample
The CSV file, stored in <DSS_HOME>/samples/resources/Products.csv
contains data about the products that are manufactured in an automobile company. Products refer to cars/motorocyles. The data table has the following columns: "ID", "Name", "Classification" and "Price". The sample data service used in this demonstration (CSVSampleService.dbs),
contains a single operation named getProducts , which lists all the products that are manufactured in the company.
See Data Services and Resources for a definition of datasources and operations.
Building the sample
The sample data service, CSVSampleService
should be deployed using the instructions in Samples Setup.
Executing the sample
The sample service can be run using the TryIt tool, which is bundled with the WSO2 Data Services Server, or a code-generated java client sample as discussed in the Data Services Clients section.
Follow the steps below to demonstrate this functionality using the TryIt tool:
- Log in to the management console of your server and click List under Services in the navigator. The
CSVSampleService
will be listed here. - Click Try this service to open the TryIt tool.
- Select the "getProducts" operation and click Send to execute the request. You will get the product list in the response as shown below.