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.
...
Start the WSO2 ESB profile.
Panel borderColor #542989 bgColor #ffffff borderWidth 1 Localtabgroup Localtab active true title On MacOS/Linux/CentOS Open a terminal and execute the following command:
Code Block sudo wso2ei-6.45.0-integrator
Localtab title On Windows Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.45.0 Integrator. This will open a terminal and start the ESB profile. - Open the ESB profile's Management Console using https://localhost:9443/carbon, and log in using
admin
as the username and the password. - Click Create under Data Service.
Add a name for the data service.
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 title What 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:
- Add a new employee to the database
- 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.
- Click Next and then click Add New Datasource.
Connect to the Company database that you defined above.
Datasource ID Datasource Datasource Type RDBMS Datasource Type (Default/External) Leave Default selected. Database Engine MySQL Driver Class com.mysql.jdbc.Driver
URL jdbc:mysql://localhost:3306/Company
User Name Enter your MySQL server's username. Password Enter your MySQL server's password.
If you have not assigned a password, keep this field empty.- Click Save and then click Next to go to the Queries screen.
Click Add New Query to specify the query details:
Enter addEmployeeQuery as the query ID.
Enter the following SQL dialect:
Code Block insert into Employees (EmployeeNumber, FirstName, LastName, Email,OfficeCode) values(:EmployeeNumber,:FirstName,:LastName,:Email,:OfficeCode)
Click Generate Input Mapping and input mappings are generated automatically.
Click Save.
Click Add New Query to Create another query for the Company datasource:
Enter selectEmployeebyIDQuery as the query ID.
Enter the following SQL dialect:
Code Block select EmployeeNumber, FirstName, LastName, Email, OfficeCode from Employees where EmployeeNumber=:EmployeeNumber
Generate input and output mappings:
Click Generate Input Mapping and input mappings are generated automatically for the employee number.
Click Generate Response to automatically generate the output mappings for the fields in the Employees table.
Click Save.
Click Next and then click Add New Operation.
Create two operations to add and select employees.
Enter the following details to create the addEmployeeOp operation that adds new employees to the database.
Operation Name addEmployeeOp
Query ID addEmployeeQuery
- Save the operation.
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 Name selectEmployeeOp
Query ID selectEmployeebyIDQuery
Click Save.
Click Finish.
...