Versions Compared

Key

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

The request box feature allows you to invoke multiple operations (consecutively) to a datasource using a single operation. Follow the steps given below to define a data service that can invoke request box operations:

Table of Contents

...

Setting up a datasource

Follow the steps given below to set up a MySQL database for this tutorial.

  1. Install the MySQL server.
  2. Download the JDBC driver for MySQL and copy it to your <EI_HOME>/lib directory.
  3. Create a database named Company.
  4. Create the following tables:

    • Offices table:

      Code Block
      CREATE TABLE `Offices` (`OfficeCode` int(11) NOT NULL, `AddressLine1` varchar(255) NOT NULL, `AddressLine2` varchar(255) DEFAULT NULL, `City` varchar(255) DEFAULT NULL, `State` varchar(255) DEFAULT NULL, `Country` varchar(255) DEFAULT NULL, `Phone` varchar(255) DEFAULT NULL, PRIMARY KEY (`OfficeCode`));
    • Employees table:

      Code Block
      CREATE TABLE `Employees` (`EmployeeNumber` int(11) NOT NULL, `FirstName` varchar(255) NOT NULL, `LastName` varchar(255) DEFAULT NULL, `Email` varchar(255) DEFAULT NULL, `JobTitle` varchar(255) DEFAULT NULL, `OfficeCode` int(11) NOT NULL, PRIMARY KEY (`EmployeeNumber`,`OfficeCode`), CONSTRAINT `employees_ibfk_1` FOREIGN KEY (`OfficeCode`) REFERENCES `OFFICES` (`OfficeCode`)); 
  5. Insert the following data into the Offices table:

    Code Block
    INSERT INTO Offices VALUES (1,"51","Glen Street","Norwich","London","United Kingdom","+441523624");
    INSERT INTO Offices VALUES (2,"72","Rose Street","Pasadena","California","United States","+152346343"); 

...

Define a data service to invoke request box operations

Let's create a data service using the Create Data Service wizard:

  1. Log into the management console of the ESB profile and click Create under Data Service.
  2. Add a name for the data service and select the Enable Boxcarring and Disable Legacy Boxcarring Mode check boxes.

    Note

    The Enable boxcarring option enables both the legacy boxcarring and the new request box methods. You can disable the legacy boxcarring method and use the request box method by selecting the Disable Legacy Boxcarring Mode option.

  3. Click Next and then click Add New Datasource.
  4. Connect to the Company database that you defined above. For instructions, see Exposing an RDBMS as a Data Service.
  5. Click Save, and then click Next to go to the Queries screen.
  6. 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, lastName, firstName, email,officecode) values(:employeeNumber,'test','test',:email,:officecode)
  7. Click Generate Input Mapping and input mappings will be generated automatically:

  8. Click Save.

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

    1. Enter selectOfficebyEmployee as the query ID.

    2. Enter the following SQL dialect:

      Code Block
      select officecode,addressline1,addressline2,city,state,country,phone from Offices where officecode=?
  10. Generate input and output mappings:

    1. Click Generate Input Mapping and input mappings will be generated automatically for the office code field:

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

  11. Click Save.

  12. Click Next and then click Add New Operation to create an operation for the addEmployeeQuery query as shown below.

  13. Click Save.

  14. Click Add New Operation to create another operation to invoke the selectOfficebyEmployee query:

  15. Click Save and then click Finish.

Invoking the data service 

The Deployed Services  window allows you to manage data services. You can try the data service you created by using the TryIt tool in this screen, which is in your product by default.  

...