[Download] | [Documentation Home] | [Release Note]

Data Source Support

Data Services Server provide support for the following data sources.

Data Source support for RDBMS

This section explains how a Data Service can be created using a relational database table as a datasource.

Copying the JDBC Driver

As the first step to create the data service for RDBMS you should copy the relevant JDBC driver into CARBON_HOME/repository/components/lib directory. (e.g:- cp mysql-connector-java-5.XX-bin.jar /home/user/wso2ds/wso2-dataservices-XX/repository/components/lib). There are three ways to create a data service using a relational database.

Steps to create a data service for relational database

Let's use the graphical wizard to create the data service for RDBMS. To start the wizard click on 'Create' link on your left hand menu. (Figure 1)



DS

Figure 1: Create data service for relational database



In the first screen that appears, enter a name for your Data Service('DataServiceSample1').(Figure 2)



DS Figure 2: Create data service

Enter data source Id and select 'RDBMS' as 'Data Source' type.Enter values to be used to connect to database.

DS Figure 3: Configure Data Source To find more details about data source configuration parameters refer to http://commons.apache.org/dbcp/configuration.html.

Enter query details using which values will be extracted and specify how SQL response is mapped to output XML.



DS

Figure 4: Configure Query Information



Following query needs two parameters to be supplied for execution. Input Mapping section is used to specify input parameters.



DS

Figure 5: Input parameters



Once you add a query, it will be listed as follows.



DS

Figure 6: View query



Create an operation and select a query to be executed when this operation is called.



DS

Figure 7: Add operation



When query accepts parameters, there is an additional step. Following screen shows it.



DS

Figure 8: Add operation with input parameters



Existing operations will be listed as follows.



DS

Figure 9: View operations



Click 'Finish' button to complete the wizard.



Deployed Services will be listed as follows.



DS

Figure 10: Deployed services



Following statistics are available for a service. Options mentioned in lower part of the screen can be applied to a service.



DS

Figure 11: Service statistics



Click on 'Try it' link and you will be directed to a screen similar to following.



DS

Figure 12: Invoke service using Try-it



This is how Try-it shows results after service invocation.



DS

Figure 13: Service invocation



If there are parameters, Try it allows you to enter them as well.



DS

Figure 14: Service invocation-with parameters



WSDL for the service can be viewed by clicking 'WSDL' link.



DS

Figure 15: WSDL

RDBMS data source

For the RDBMS data source, select the data source type as 'RDBMS' after naming the data source. Enter values to be used to connect to the database.



DS

Figure 16: Creating the data source for RDBMS



Carbon Data Source

For the Carbon data sources, you have to create the carbon data source first.

To create the carbon data source click on the Data Sources menu item under the configuration.



DS

Figure 17: Create Carbon Data Source menu



Click on 'Add Data Source' link in Data Sources page which will direct you to a page where you can enter the details for the data source. You can test the connection by click on 'Test Connection' button on bottom of the page. Add data source page with entered details is showing below.



DS

Figure 18: Creating the Carbon Data Source



Once you have created the carbon data source, you can use it inside the data service. Select the 'Carbon Data Source' as the type of the data source in Add data source page in the data services wizard. Select the carbon data source name which you have created from the drop down list.



DS

Figure 19: Creating the data source for Carbon Data Source



JNDI Data source

For the JNDI data source, first define a 'JNDI' typed carbon data source. Enter values to be used to connect to the database.



DS

Figure 20: Creating the carbon data source for JNDI



When creating the data service select the data source type as 'JNDI' and enter the values to be used to connect to the previously created JNDI enabled data source.



DS

Figure 21: Creating the data source for JNDI