Versions Compared

Key

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

In this tutorial, you define a data service that can invoke request box operations. The request box feature allows you to invoke multiple operations (consecutively) to a datasource using a single operation.

...

  1. Start the WSO2 ESB profile.

    Panel
    borderColor#542989
    bgColor#ffffff
    borderWidth1
    Localtabgroup
    Localtab
    activetrue
    titleOn MacOS/Linux/CentOS

    Open a terminal and execute the following command:

    Code Block
    sudo wso2ei-6.45.0-integrator
    Localtab
    titleOn Windows
    Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.45.0 Integrator. This will open a terminal and start the ESB profile.
  2. Open the ESB profile's Management Console using https://localhost:9443/carbon, and log in using admin as the username and the password.
  3. Click Create under Data Service.
  4. Add a name for the data service.

  5. Select the Enable Boxcarring check box.
    As a result of selecting this check box, the Disable Legacy Boxcarring Mode check box will appear on your screen as shown below. Select this new check box (Disable Legacy Boxcarring Mode) as well.

    Note
    titleWhat is Boxcarring and Request Box?

    Boxcarring is a method of grouping a set of service calls so that they can be executed as a group (i.e., the individual service calls are executed consecutively in the specified order). Note that we have now deprecated the boxcarring method for data services. Instead, we have replaced boxcarring with a new request type called request_box

    Request box is simply a wrapper element (request_box), which wraps the service calls that need to be invoked. When the request_box is invoked, the individual service calls are executed in the specified order, and the result of the last service call in the list are returned. In this tutorial, we are using the request box to invoke the following two service calls:

    1. Add a new employee to the database
    2. Get details of the office of the added employee

    When you click the Enable Boxcarring check box for the data service, both of the above functions (Boxcarring and Request box) are enabled. However, since boxcarring is deprecated in the product, it is recommended to disable boxcarring by clicking the Disable Legacy Boxcarring Mode check box.

  6. Click Next and then click Add New Datasource.
  7. Connect to the Company database that you defined above.

    Datasource IDDatasource
    Datasource TypeRDBMS
    Datasource Type (Default/External)Leave Default selected.
    Database EngineMySQL
    Driver Classcom.mysql.jdbc.Driver
    URLjdbc:mysql://localhost:3306/Company
    User NameEnter your MySQL server's username.
    PasswordEnter your MySQL server's password.
    If you have not assigned a password, keep this field empty.
  8. Click Save and then click Next to go to the Queries screen.
  9. Click Add New Query to specify the query details:

    1. Enter addEmployeeQuery as the query ID.

    2. Enter the following SQL dialect:

      Code Block
      insert into Employees (EmployeeNumber, FirstName, LastName, Email,OfficeCode) values(:EmployeeNumber,:FirstName,:LastName,:Email,:OfficeCode)
    3. Click Generate Input Mapping and input mappings are generated automatically.

    4. Click Save.

  10. Click Add New Query to Create another query for the Company datasource:

    1. Enter selectEmployeebyIDQuery as the query ID.

    2. Enter the following SQL dialect:

      Code Block
      select EmployeeNumber, FirstName, LastName, Email, OfficeCode from Employees where EmployeeNumber=:EmployeeNumber
    3. Generate input and output mappings:

      1. Click Generate Input Mapping and input mappings are generated automatically for the employee number.

      2. Click Generate Response to automatically generate the output mappings for the fields in the Employees table.

    4. Click Save.

  11. Click Next and then click Add New Operation.

  12. Create two operations to add and select employees.

    1. Enter the following details to create the addEmployeeOp operation that adds new employees to the database.

      Operation NameaddEmployeeOp
      Query IDaddEmployeeQuery
    2. Save the operation.
    3. Click Add New Operation and enter the details as shown below to create the selectEmployeeOp operation that gets the details of an employee from the database.

      Operation NameselectEmployeeOp
      Query IDselectEmployeebyIDQuery
    4. Click Save.

  13. Click Finish.

...