Skip to main content Skip to complementary content

Configuring the components

Procedure

  1. Double-click the cBeanRegister component to display its Basic settings view in the Component tab.
  2. The cBeanRegister component registers a Java bean, in which the customer information is set with the firstName, lastName, city, and id values.
    In the Id field, enter "customers" to name the bean.
    Select the Customized option and enter the following code in the Code box to create two customers and set the firstName, lastName, city, and id values for each of them:
    beans.Customers customers = new beans.Customers();
    
    beans.Customer customer = new beans.Customer();
    customer.setFirstName(TalendDataGenerator.getFirstName());
    customer.setLastName(TalendDataGenerator.getLastName());
    customer.setCity(TalendDataGenerator.getUsCity());
    customers.addCustomer(customer);
    
    customer = new beans.Customer();
    customer.setFirstName(TalendDataGenerator.getFirstName());
    customer.setLastName(TalendDataGenerator.getLastName());
    customer.setCity(TalendDataGenerator.getUsCity());
    customers.addCustomer(customer);
    
    beanInstance = customers;
  3. Double-click the cREST component to display its Basic settings view in the Component tab.
  4. The cREST component is used to provide the REST service.
    In the Endpoint field, type in the endpoint URL where the Web service will be provided, "http://localhost:8040/services/customers" in this example.
    From the Type list, select Manual to determine the REST API mapping manually.
    In the REST API mapping table, click [+] to add a row in the table. In the Output Flow field, enter getAllCustomers as the name of it. Select GET in the HTTP Verb list. Keep the default settings in the other columns.
  5. Double-click the cSetBody component to display its Basic settings view in the Component tab.
  6. Select SIMPLE from the Dataformat list. In the Expression field, enter "${ref:customers}" to refer to the bean defined in the cBeanRegister component as the message body of the service response.
  7. Keep the default settings of the cLog component to log the message exchanges.
  8. Press Ctrl+S to save your route.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!