The purpose of this guide is to get you started on creating and invoking a data service using WSO2 Data Services Server (WSO2 DSS) as quickly as possible. See the following topics for details:
Table of Contents | ||||
---|---|---|---|---|
|
...
Introduction and key concepts
...
Open a terminal and navigate to the
<DSS_HOME>/bin
directory and execute the DSS startup script using one of the following commands:- On Windows:
wso2server.bat
- On Linux:
sh wso2server.sh
- On Windows:
When the product is started, the URL of the Management Console will be shown in the terminal as follows:
INFO {org.wso2.carbon.ui.internal.CarbonUIServiceComponent} - Mgt Console URL : https:
//10.100.5.65:9443/carbon/
Copy this URL to your browser to open the Management Console.
Log in to the management console using the default administrator credentials: admin/admin.
In the left navigator, go to the Main tab and click Services -> Add -> Data Service -> Create. This will open the Create Data Service wizard.
In the Data Service Name field, enter 'MyFirstDS' as the name. Leave the default settings of all other options.
- Click Next. This will take you to the page for adding datasources.
- Click Add New Datasource. You can now specify the datasource details.
- In the Datasource ID field, enter 'MyDS'.
- In the Datasource Type field, select RDBMS from the list of values.
- You will now be prompted to enter details of your RDBMS:
- Enter the following details of your MySQL database in the relevant fields as shown above:
- Database Engine: MySql
- Driver Class: com.mysql.jdbc.Driver
- URL: jdbc:mysql://localhost:3306/employeedb
- User Name: root
- Password: (Leave this blank)
- Click Save to save the datasource.
- Click Next. This will take you to a new page for adding queries to your service.
- Now we will create a query to obtain all the employee details saved in the database.
- Enter a name for the query in the Query ID field. We will use 'QueryAll'.
- All datasources created for the data service will be listed for the Datasource field. Select MyDS from this list.
- Specify the SQL statement in the SQL field. We will use a SELECT statement to query for all the employee details in the database as shown below.
We must now specify output mappings to determine how the information in the database should be displayed in the query output. We will be needing three columns (ID, Name and Address) to display the employee details. Therefore, we need to create three output mapping entries as explained below.Anchor output mapping output mapping - Click Add New Output Mapping and the following screen will open. You can now enter the first output mapping for employee ID as shown below.
- Click Add to create the output mapping.
- Repeat the steps using the following information to create the remaining two output mappings:
- When you have created all the columns as output mappings, they will be listed as follows:
- Click Add New Output Mapping and the following screen will open. You can now enter the first output mapping for employee ID as shown below.
- Click Main Configuration to return to the main page.
- Click Next. This will take you to a new page for connecting operations to each of your queries.
- Enter a name for the operation in the Operation Name field. We will use 'getEmployees'.
- All the queries defined for the data service will be listed for the Query ID field. Select 'QueryAll'.
- Save the operation.
- Click Finish to complete the data service creation. The 'MyFirstDS' data service is now listed as a deployed data service.
...
- Go to Services -> List to open the Deployed Services page.
- Click the data service (MyFirstDS) to open the service dashboard:
See that the URL of the 'MyFirstDS' data service is listed under Endpoints: https://10.100.5.65:9443/services/MyFirstDS/ - You can execute the
getEmployees
operation using the above URL. Simply copy this URL followed by the operation name as shown below.
https://10.100.5.65:9443/services/MyFirstDS/getEmployees - The result will be the same as with the TryIt tool:
...