The WSO2 Data Services Server augments Service Oriented Architecture (SOA) development efforts by providing an easy to use platform for integrating data stores, creating composite data views, and hosting data services. This blog post is written to help users to getting started with WSO2 DSS with writing a data service to execute a stored procedure which is defined in a database.
Prerequisites
Before starting the implementation, you need the following things to be downloaded and installed.
1. Download WSO2 Data Services Server and install.
2. Download mysql server and install.
Once you have installed both WSO2 DSS and mysql in your enviornment, you can proceed to the next step.
Creating the stored procedure in mysql
1. Connect to mysql server with the following command.
mysql -u root -p
Enter password:
2. Create a sample databasae.
DROP DATABASE IF EXISTS ESB_SP_SAMPLE;
CREATE DATABASE ESB_SP_SAMPLE;
3. Create a table using the following statement.
USE ESB_SP_SAMPLE;
DROP TABLE IF EXISTS company;
CREATE TABLE company(name VARCHAR(10), id VARCHAR(10), price DOUBLE, location VARCHAR(10));
4. Inserts some data to the company table using following statements
INSERT INTO company VALUES ('WSO2','c1',2.9563,'SL');
INSERT INTO company VALUES ('IBM','c2',3.7563,'US');
INSERT INTO company VALUES ('SUN','c3',3.8349,'US');
INSERT INTO company VALUES ('MSFT','c4',3.2938,'US');
5. Create necessary Stored Procedures.
DROP PROCEDURE If EXISTS InsertRequestData;
CREATE
PROCEDURE InsertRequestData(compName VARCHAR(10), compId VARCHAR(10),
compPrice DOUBLE, compLocation VARCHAR(10)) INSERT INTO company
VALUES(compName,compId,compPrice,compLocation) ;
Configuring the DSS to work with the mysql database
Download the mysql connector library from here and copy that file in to DSS_HOME/lib/extensions/ (create a directory if not exists) directory.
If you are a Windows user, you need to run wso2server.bat file, or, for a Linux user you need to run wso2server.sh script using command prompt or shell to start WSO2 Data Services server.
Writing the Data service to access the stored procedure
Now you have configured the DSS to work with mysql and created the stored procedure. Then you need to create the dataservice configuration file as below.
hi, how can I write the client code with the wsdl file of the service?? can you provide some sample codes?
ReplyDeleteHi, Can we insert parent and child data (nested data) using store procedure
ReplyDeleteHi Have you tried making that into a rest resource? Especially with a stored procedure that has an out param? I am getting errors because i don't know how to eliminate the out param from the query parameters in the resource section.
ReplyDelete