WSO2 Data Services plugin for Eclipse WTP

WSO2 Data Services 1.0 provides you with a IDE plugin which can be integrated to Eclipse WTP. You can create and deploy data services to a remote or local data services server from IDE. This post demonstrates how a simple MySQL data service is created and deployed using Eclipse WTP.

Pre-requisites

Download and install WSO2 Data Services 1.0
Download and install Eclipse WTP

We will create a data service using MySQL. Please follow the instructions provided in WSO2 Data Services Quick Start Guide to create a data base and populate data.

Step 1

Download wso2 data services eclipse plugin (org.wso2.ws.dataservices.ide_1.0.0) from here and copy it to Eclipse_home/plugins directory.

Start Eclipse and select a new workspace. Select Workbench to go to the work bench.

Step 2
Open the new wizard selection window (File --> New -- Other). If you have copied org.wso2.ws.dataservices.ide_1.0.0.jar to the eclipse plugins directory correctly, you will see WSO2 Data service wizard option in there.



Select wso2 dataservice creation wizard and click on Next. The initial configuration screen of the Data Service Creation wizard will be displayed as follows.



Select Try it after deploying check box.
We are going to create a data service through IDE wizard and deploy it to a wso2 dataservice server running in localhost. (You can deploy data services to a remote server as well).
Therefore, you need to provide truststore and administrator credentials in that server.

Click on Set truststore. Browse for wso2carbon.jks which is located at your WSO2DS_Home/conf directory. (WSO2DS_HOME is the location where you unzipped wso2 dataservice 1.0 binary distribution)
You will be prompted to enter password for the trust store. Enter wso2carbon and click ok.

Click on Set Credentials to enter username and password of the target data service server.
Enter admin as the user name and password.

Click on Next to proceed through the wizard.

Step 3

Now you are at the step one of data service configuration wizard.
Give a name for the service (i.e:-IDEDataService)

Click on Add button to add a new data source. Since we use MySQL data source, select RDBMS as the data source type and click ok.

You will get a message saying "Currently typed database driver class does not reside in the class path. Please provide correct path to the jar file". Click ok.

Now you will be directed to the mySQL database configuration window.



Enter the following values for MySQL database configuration.

Driver Class = com.mysql.jdbc.Driver
JDBC URL = jdbc:mysql://localhost:3306/employeedb
Enter the user name and password of your MySQL db.

Enter jar path to driver class (mysql-connector-java-*-bin.jar). Then click on Test Connection button. You should get "Test Connection Successful" message.
Click "OK" to finish the database configuration.

Click "Next" in the WSO2 Data service wizard Step one to move to the next step.

Step 4

Now you should be in the step 2 of the wizard. Click on Add New Query. Following window will be displayed.



Select default data source. Enter the follwoing values for the rest of the fields.

Query ID = allEmployees

SQL Statement = select * from employee

Grouped by Element = employees

Row name = employee

Row namespace = http://test.org

Now click on 'New' button under 'Result (Output mapping)' window. 'Add New Output Mapping' window will be popped up. Add three output mappings as follows

  1. Mapping Type = Element

    output field name = id

    SQL Column Name = id

  2. Mapping Type = Element

    output field name = name

    SQL Column Name = name

  3. Mapping Type = Attribute

    output field name = address

    SQL Column Name = address

We have added one query to our data service configuration.

Click on 'OK' button at the "Query Configuration" window. You will be directed back to the step two of data service wizard and your new query will be listed there.

Click Next button to continue. Step three of the data service configuration wizard will be displayed.

Step 5

Click on 'Add New Operation' button. Enter a name for the operation (i.e: getAll) and leave the default settings and click ok.

By now, we have completed all data service cinfiguration steps. Click Finish to deploy the service.

(Make sure wso2 data service server instance is running in your host before finishing the IDE wizard. You can start it by running wso2server.bat located at WSO2DS_HOME/bin directory)

If all are correct you will get "Data Service deployed successfully" message. Also, a browser will be popped up withTryit page where you can easily test the service.

Comments

Nice Charitha, This looks great !! and it came as the 3 rd hit in google for me when I typed wso2 eclipse plugins
Sagar said…
Hi Charitha,

Could you please tell me how to configure Oracle DB server drivers? since i notice while configuring only MySQL and Apache Derby database types are showing? Your suggestion would be much appreciated.

Regards,
Sagar

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