Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

...

  1. Download and install MySQL using Homebrew. 

  2. Open a terminal and execute the following command to start your MySQL database:

    Code Block
    mysql.server start
  3. Access the MySQL prompt by giving the user name and password. By default the user name is 'root' and the password is blank.

    Code Block
    mysql -u root -p
  4. Create the sample database named employeedb using the following command: 

    Code Block
    create database employeedb;
  5. Open the employeedb database you just created using the following command:

    Code Block
    use employeedb;
  6.  Create one table in the database using the following command:

    Code Block
    create table employee(id VARCHAR(10) NOT NULL PRIMARY KEY, name VARCHAR(100), address VARCHAR(100));

    This command will create the following table in the database:

  7. Insert employee data into the employee table as follows:

    1. The first employee:

      Code Block
      insert into employee values('01','john','Boston');
    2. The second employee:

      Code Block
      insert into employee values('02','Micheal','Dallas');
    3. The third employee:

      Code Block
      insert into employee values('03','richard','Chicago');
  8. You can see the data that you have added to the employee table of the employeedb database by executing the following command:

    Code Block
    SELECT * FROM employee

    The result will be as follow:

...

  1. Click Add New Datasource. You can now specify the datasource details. 
    1. In the Datasource ID field, enter 'MyDS'.
    2. In the Datasource Type field, select RDBMS from the list of values. 
  2. You will now be prompted to enter details of your RDBMS:
    Edit datasources page
  3. Enter the following details of your MySQL database in the relevant fields as shown above:
  4. Click Save to save the datasource.
  5. Click Next. This will take you to a new page for adding queries to your service. 

...

  1. Now we will create a query to obtain all the employee details saved in the database.
    1. Enter a name for the query in the Query ID field. We will use 'QueryAll'.
    2. All datasources created for the data service will be listed for the Datasource field. Select MyDS from this list.
    3. 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.
      Query detailsImage RemovedImage Added
    4. Anchor
      output mapping
      output mapping
      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 (IDName and Address) to display the employee details. Therefore, we need to create three output mapping entries as explained below.
      1. 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.
        Add output mappingImage Removed
      2. Click Add to create the output mapping.
      3. Repeat the steps using the following information to create the remaining two output mappings:
        • Mapping Type: Element

          Output field name: Name
          Data source column Name: name
          Schema Type: xs:string

        • Mapping Type: Attribute

          Output field name: address
          Data source column Name: address
          Schema Type: xs:string

      4. When you have created all the columns as output mappings, they will be listed as follows:
        Add output mappingImage Removed
  2. Click Main Configuration to return to the main page.
  3. Click 
    1. for these fields. Click Generate Response to automatically create output mappings as shown below.
      Image Added
  4. Click Next. This will take you to a new page for connecting operations to each of your queries.

...

  1. Go to Services -> List to open the Deployed Services page.
  2. Click the data service (MyFirstDS) to open the service dashboard:
    Service dashboard
    See that the URL of the 'MyFirstDS' data service is listed under Endpointshttps://10.100.5.65:9443/services/MyFirstDS/
  3. 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
  4. The result will be the same as with the TryIt tool:
    Operation result using HTTP GET request

This concludes the quick start guide for WSO2 DSS 3.5.01. You can find more advanced use cases in the Tutorials.