Pages

Friday, July 3, 2015

WSO2 DSS for absolute beginners

WSO2 Data Services Server is 100% open source product that can be used to create and deploy data services.

What is a Dataservice?

Most businesses require secure and managed data access across these federated data stores, data service transactions, data transformation and validation.

An organization's data exposed as a service, decoupled from the infrastructure where it is stored, is called data services in service oriented architecture (SOA).


If I explain in most simple way: Data service exposes database or database content or any other data source as a web service. In most simplest explanation is it just wraps database (or table, multiple tables) or any other data source and expose the data as web service in more controlled, meaningful manner. 


Data Services provide a convenient mechanism to configure a Web service interface for data in various data sources such as relational databases, CSV files, Microsoft Excel sheets, Google spreadsheets etc


As an example, let’s say you want expose employee information in the database which employee personal information are in emplyeeInfo table and work related information is in another table called employeeWork table. And think you want to expose those information as a web service when requester sends the employee id and the service returns employee personal information with his work performance information. Simply you can create web service using WSO2 DSS by wrapping the SQL query to retrieve that information and present in the response. 


The beauty with DSS is, it handle all dirty work such as creating database connection, database connection pool handling, executing SQL queries, mapping resultant data to the response, etc. which is an unusual overhead to for development. With WSO2 DSS it just simply a web service call, so developers can more concentrate on the business logic / use case.


You can get more feeling about DSS by following  


Generating simple data service using WSO2 DSS Generate wizard

Now we will try out generate data service for given database table. In generate it will create data service with CRUD operations for the table.


Refer https://docs.wso2.com/display/DSS322/Installing+the+Product for installation instructions and refer https://docs.wso2.com/display/DSS322/Running+the+Product for running product instructions.


  1. After starting the product and then login to the management console (default username: admin password: admin)
  2. First we have to first define data source
NOTE : before creating datasource you have to copy database jdbc driver relevant to your database to <PRODUCT_HOME>/repository/components/lib.
    1. Go to Configure tab → Data Sources
    2. Will get list of data sources currently configured as follows


    1. Click “Add Data Source” and provide information related to the database as follows:



Click Test Connection to verify provided information
Can provide data source connection pool parameters by expanding “Data Source Configuration Parameters” (refer: https://docs.wso2.com/display/DSS322/Configuring+the+Datasource+Connection+Pool+Parameters )
Click save when finished.
  1. Now we can generate dataservice
    1. Go to Main → Click “Generate” under Data Service
    2. Select previously created Data Source from the drop down and give the database name

NOTE : For the “Database name”, you have to give the actual database (schema) name. Most of the time people get confused with this. In this case “DSS_DB” which created with the command “create database DSS_DB;”
Then click “Next”


    1. You will get list of all available tables in the database as shown below. You can to select tables which need to expose as data service and click “Next”




    1. In “Service Generation” section you have to provide Data Service Namespace and the Data Service Name. And select whether you need single service with CRUD operation for all the tables or multiple services per table (service per table)

    1. After click Next you will get notice that service deployed successfully.

  1. Now you have finished creating data service. If you navigate to “List” under Services in Main tab you will find created data service. You can tryout it by clicking Try this service.



No comments:

Post a Comment