Tuesday, September 16, 2008

Create basic data service using WSO2 Data Service


This tutorial describes how you create simple data service using WSO2 Data Service. WSO2 Data Service is latest web service application introduced by the WSO2.Before you create your data service you have to setup WSO2 Data Service Server. Following are the prerequisites for set up the Server.

Prerequisites

  1. Download WSO2 Data Service

  2. Download MySQL (This tutorial explain create a data service using MySQL Database)

  3. Download JDK 1.5 or Higher

Before setup WSO2 Data service you have to install JDK and MySQL. Once you set up JDK and MySQL you have to setup sample database. here's the sample database format.

Database Name : Test

Table Format : Table Name - student

untitled

You can use following SQL Command in MySQL Command prompt for creating a database.

mysql>create database Test;

mysql>CREATE table student(Name varchar(100),Marks int(50),Status varchar(100));

mysql>insert INTO student values ('Chamara',88,'Pass');

mysql>insert INTO student values ('John',76,'Pass');

mysql>insert INTO student values ('Suminda',69,'Pass');

mysql>insert INTO student values ('Peter',41,'Fail');

Next step is setup the WSO2 data service server. Extract the downloaded WSO2 Data service pack in any location.

Then you need to add MySQL database driver to WSO2 data service. thus otherwise you cannot access MySQL database from the WSO2 Data service. for that downloadmysql-connector-java-5.0.4-bin.jar and copy it to “\lib\extensions” inside data service folder.

If you are windows user you have to run wso2server.bat file or if you are Linux user you have to run wso2server.sh script using command prompt or shell to start WSO2 Data Service Server.

Once server start you can browser data service user interface using browser by using following URL.

For local Access :https://localhost:9443/ds/index.html

For Remote Access :https://[ServerIP]:9443/ds/index.html

[ServerIP] = IP address of the WSO2 data service server

Now you will see WSO2 Data service User interface.

Mainpage

To login to the Management Console Use following default user Credentials in sign in page.

User Name : admin

Password : admin

After login you can see WSO2 Data Service Home page as follows.

MgtConsole

In this tutorial use only few major functionalities in WSO2 Data service application. Following are the two major functionalities use in this tutorial.

  • Data Services (See above Screen shot) - Displays List of data services currently deployed in the server.

  • Add (See above Screen shot) - Use to create new data service.

  • Try it tool - use check output of the data service

( For more information about WSO2 Data Services functionalities,refer User guide.)

Now you are ready to create new basic data service using MySQL Database. Follow there steps to create your data service. Chamara = 380

  1. Click "Add" and insert data service name and description and click "next"

DataSe1

2. Select "RDBMS" Data Source Type in Step-2 window and click Add button for configure the data base connection

(For Integrate Relational databases like MySQL,MSSQL Server,Oracle etc RDBMS data source type should select. in addition to that WSO2 Data service support MS Excel,CSV and JNDI Data Sources also.)

DataSe2

3. Insert data service connection id and select data base type as follows. you can insert any name for Connection id )

DataSe3

4. Once you fill above fields Driver class will automatically load.

5.JDBC url you have to change for your database information

Default JDBC url display as "jdbc:mysql://[machine-name/ip]:[port]/[database-name]".for a example your database machine ip is 10.100.1.149 and MySQL port 3306 and database name id "Test", this is the way to fill up JDBC url.

jdbc:mysql://10.100.1.149:3306/test

6. Insert user name and password for database login

DataSe4

7. Click Test Connection button for establish data base connection.(if you are successfully configured in data service following message will applier) 545 chamara

DataSe5

8. Click Ok in configuration window and click next button in Step-2 window.

9.In Step 3 window click New query button for Add new query,

10. Insert following information in to add new query window.

Query ID = Name of the query (Test Query)

Data Source = Select data source connection created earlier. (Sample Connection)

SQL Statement = select * from Test

Grouped by element = Name of the group element (BaseElement)

Row name = Name of the sub element (Element)

DataSe6

11. Insert output mappings for get out put from the data service

for the click add new output mapping button and select element mapping type, insert output field name and SQL Column name. (output field name can be any name, but SQL Column name should equal to the database column name )

DataSe7

12. Add all the output mapping and click ok button.

13. click Next button for add new operation..

14. Click add new Operation button and type new operation name, select a query and click ok button.

DataSe8

15.Click Finish button for finish data service creation process.

Now you finished the data service creation process. you will see the created data service in data service list page.

DataSe9

For checking the data service you can use Try-it tool.fot that click "MyDataService"link in Service list.you will see page as follows.

DataSe10

Click Try this Service link and click Sample Operation button for get the output of the data service

DataSe11

Finally you will the the output as follows.

DataSe12

1 comment:

Rony said...

Thanks a bunch for sharing this with all folks you actually know what you are talking about! Bookmarked. Please additionally seek advice from my website =). We could have a hyperlink trade arrangement among us.
Create a MySQL database.