Getting started with WSO2 Data Services

As I mentioned in a previous post, WSO2 Data Services is now available for you to download and try out. WSO2 Data Services is an open source product and it is available under apache license.

The objective of this post is to get you start with WSO2 Data Services with minimum configuration steps. You can find more details of WSO2 Data Services solution from online documentation

Step 1
Download and install wso2 data service solution. You may download the latest beta2 version from here. Just extract in to a directory in your file system.
We refer this directory as WSO2DS_HOME.

Step 2
Start wso2 data services solution. Go to WSO2DS_HOME/bin and run wso2server.bat{sh}

Step 3
WSO2 Data services provides a web service interface for data stored in relational data bases, csv or Microsoft Excel files. Since our intention is to get our first data service running as quicker as possible I will use a simple csv file as the data source.
Open a text editor and create a csv file as follows.




Save this file as employee.csv.

Step 4
Access WSO2 Data Services management console. Open a browser and go to http://localhost:9443/ds
Click on Sign-in link at the top right corner. Enter username = admin and password = admin as login credentials.
You will be directed to the home page of Data Services management console.

Step 5

Click on Add from the left navigation menu. The step one of data service creation wizard will be shown.
Enter csvservice as the Service name and click on Next.

Step 6

Select csv as the data source type and click on Add.

Step 7

In CSV Data source configuration window, enter the following values.
Id = 1
CSV File location = D:\temp\employee.csv
Column Seperator = ,
Starting Row = 2
Max. no of rows to read = -1
Headers Available = TRUE
Column Selection (You can click on the column names specified in the drop down. Then it will add column numbers according to the sequence of selection)
id as column no:1
name as column no:2
address as column no:3

Step 8

Click "Next" from the data service wizard step 2. You will be directed to the step 3 where you can create queries for the service.
Click on "New Query" button.
Add New Query window will be popped up. Enter the following values.

QueryID = q1
DataSource = 1
Grouped by element = emps
Rowname = emp

Click on "Add New output mapping" button. In "Add new Output mapping" window, enter the followings. (Repeat this with name and address columns as well)
Mapping Type = Element
Output field name = id
CSV Column ordinal = 1

Step 9

If query is configured as in the previous step, you should notice the following elements in the "Preview of Data service configuration" section.
<query id="q1" useConfig="1">
<result element="emps" rowName="emp">
<element name="id" column="1" />
<element name="name" column="2" />
<element name="address" column="3" />

Click on next button of the Data Service Step 3 to continue with the wizard. Step 4 will be displayed where the service operations are configured.

Click on Add New Operation button.
"Add New Operation" pop-up window will be displayed. Enter the following values.
Operation name = op1
Query = q1
Click OK

Now all the data service configuration steps are done. Click on Finsh button to deploy our CSV data service.

Step 10
csvservice will be added to the deployed services list in Deployed Services page.
Lets invoke our data service using the simplest service invocation mechanism and see we get the data stored in csv file as the output.

Click on csvservice. Service Management page will be displayed.
Select Try this service link.
Click on op1 button and you will get the results as follows.


Popular posts from this blog

Working with HTTP multipart requests in soapUI

Common mistakes to avoid in WSO2 ESB - 1 - "org.apache.axis2.AxisFault: The system cannot infer the transport information from the URL"

How to deploy JSR181 annotated class in Apache Axis2