Scenario 1: Retrieving data from a REST service from within a process using the Talend ESB REST Client connector

Talend Connectors for BPM Reference Guide

EnrichVersion
6.3
task
Design and Development
EnrichPlatform
Talend Studio

This scenario explains how to configure the Talend ESB REST Client connector to retrieve data from a REST-ful Web service provided through a demo Job of Talend ESB.

Prerequisites:

  • You have imported the ESB demo project your Talend Studio.

  • You have launched the demo Job DemoREST in the Integration perspective of your Talend Studio, and you can see information like the following when entering http://localhost:8090/services/customers in your Web browser:

Creating a new process and adding a variable for the input data (Step one)

  1. Create a new process and select the Step1 element in the process model.

  2. From the General view of the Details panel, select the Data tab and click the Add... button.

  3. Name the variable Customer_ID, select the Auto-generate form check box. You can also specify the default value in the Default value field.

  4. Click Finish. A form allowing you to enter the value for the Customer_ID variable will be generated.

Adding and configuring the Talend ESB REST Client connector

  1. From the General view, select the Connectors tab and click the Add... button. A window opens.

  2. Select Talend > Talend ESB REST Client then click Next to open the connector configuration wizard.

  3. Give the connector a name, ESB_RS_getCustomerInfo for example, and click Next.

    The REST Service configuration page opens.

  4. Configure the REST Service.

    • Fill the Endpoint URL field with the URL of the REST Service implement by the DemoREST Job, http://localhost:8090/services/customers in this example.

    • Fill in the Relative Path field with ${customer_ID}, which corresponds to the variable you just created. This allows you to enter the relative path on your Web browser when the process is executed.

    • From the Method list, select GET. This operation will retrieve data from the REST service to be called.

  5. Click Next. The Configure TESB Feature page opens to let you configure service locator information, service activity monitoring, and business correlation. As we do not use any of these options in this example, simply click Next to proceed with connector output mapping.

  6. Click the Create data button to open the [Add a new variable] dialog box.

  7. Name the variable Customer_Info, clear the Auto-generate form check box, then click Finish to close the dialog box.

  8. Click Finish to close connector configuration wizard.

Next, you have to display the Customer_Info variable in a process Web User Interface to show the returned information.

Configuring response display (Step two)

  1. Add a new task (Step 2) and an end event to the process model.

  2. Click the Step2 icon in the process model, then click the tools icon on the bottom-left corner.

  3. Select the Human icon. The task type is changed to Human.

  4. From the General view for this new human task, select the Actors tab and click the Choose... button.

  5. Select Initiator and click Finish to close the window.

  6. From the Application view, click the Entry Pageflow tab and click the Add... button next to the first table.

  7. Select the Create a new form option and click Next.

  8. On the next step, configure which variables will be shown on the form. Select the customer_Info check box and click Finish. A newly created form displays the customer_Info variable.

Running the process and retrieve customer information from the ESB REST service

  1. Click the Run process button to run the process. The studio opens the process page in your default browser.

  2. Click the Submit button to start the process and call the REST service.

  3. In the Customer_ID field, enter a customer ID, 1 for example, and click the Submit button. The HTTP GET operation is performed and the customer information corresponding to the customer ID you just entered is displayed in the Customer_Info field.