cREST
services.
cREST Standard properties
These properties are used to configure cREST running in the
Standard Job framework.
The Standard
cREST component belongs to the
Connectivity family.
Basic settings
API definition |
Click […] to browse to the OAS/Swagger 2.0 file |
Endpoint |
The service endpoint URL where the REST service is The default port is different depending on the build
type or where you run the service:
|
Type |
Select which type you want to use to provide the REST
Manual: Determine the REST API
resourceClass: Select this type to |
REST API Mapping |
This table appears when the Manual service type is selected and cREST is used as a service provider. Click [+] under the
Output Flow: Specify the name of an
HTTP Verb: Select a HTTP method
URI pattern: Fill this field with
Consumes: Select the format type of
Produces: Select the format type of
Bean class: Set the bean class when |
Resource Class |
This field appears when the resourceClass service type is selected. Enter the name |
Operation |
This field appears when the resourceClass service type is selected and cREST is used as the service consumer. |
Relative Path |
This field appears when the Manual service type is selected and cREST is used as the service consumer. |
HTTP Method |
This option appears when the Manual service type is selected and cREST is used as the service consumer.
Select a HTTP method fromGET, POST, PUT, and DELETE in the list. Warning:
When using the POST method to create an |
Content Type |
This option appears when the Manual service type is selected and cREST is used as the service consumer. Select XML, JSON, or FORM according to the media type of the content to be |
Accept Type |
This field appears when the Manual service type is selected and cREST is used as the service consumer. Select the media type the client end is prepared to accept |
Response Class |
This field appears when the Manual service type is selected and the cREST is used as the service consumer. |
Use Service Locator |
Select this check box to enable the Service Locator. |
Enable the Service Activity |
Select this check box to enable the Service Activity Note that this option works in Runtime only. When running |
Use Authentication |
Select this check box to enable the authentication option.
When the cREST |
Use Authorization |
This option is only available if you subscribed to Talend When the cREST When the cREST |
Use Business Correlation |
Select this check box to create a correlation ID in this You can specify a correlation ID in the Correlation Value field. |
Advanced settings
Log messages |
Select this check box to log the message exchanges in the |
Expose Swagger specification |
This option appears when cREST is used as a service provider, and is available If the Route is running in the Studio, the Swagger specification will be If the Route is running in Talend Runtime, the Swagger specification will be available at If the Route is running as a ESB Microservice, the Swagger specification For more information about how to build a Route to a ESB Microservice and |
Include Documentation into Swagger Spec |
This option appears when cREST is used as a For more information about the Documentation tab, |
Arguments | Set the optional arguments in the corresponding table. Click [+] as many times as required to add arguments to the table. Then click the corresponding Value field and enter a value. See the site http://camel.apache.org/cxfrs.html for available URI options. |
Usage
Usage rule |
cREST can be a start component in a |
Limitation |
Due to license incompatibility, one or more JARs required to use |
Providing and consuming a REST service using cREST
This scenario applies only to Talend Open Studio for ESB, Talend Data Services Platform and Talend Data Fabric.
This scenario demonstrates how to use the cREST component to provide and consume a REST service. To do so, two Routes are
built, a service provider Route and a consumer Route. The service provider Route will be
accessible for requests and respond with some predefined customer information. The consumer
Route will send a request to the REST service.
Building the service provider Route
This Route provides a REST Web service using the cREST component. In this Route, a cBeanRegister component is used to set the customer information in a Java bean.
The bean is then called by a cSetBody as the response of
the service.
Dropping and linking the components

-
From the Palette, drag and drop a
cREST, a cSetBody, a cLog and a cBeanRegister component onto the design workspace. -
Link the cREST, cSetBody and cLog
using the Row > Route connection. - Label the components for better identification of their roles.
Configuring the components
-
Double-click the cBeanRegister component to display its Basic settings view in the Component tab.
-
The cBeanRegister component
registers a Java bean, in which the customer information is set with thefirstName
,lastName
,
city
, andid
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 thefirstName
,lastName
,
city
, andid
values for each of
them:123456789101112131415beans.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; -
Double-click the cREST
component to display its Basic settings
view in the Component tab. -
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. -
Double-click the cSetBody
component to display its Basic settings
view in the Component tab. -
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. -
Keep the default settings of the cLog component to log the message exchanges.
-
Press Ctrl+S to save your
route.
Viewing code and executing the Route
-
Click the Code tab at the
bottom of the design workspace to have a look at the generated code.As shown in the code, the Route is builtfrom
cREST_1
, set message body incSetBody_1
and then tocLog_1
. -
Click the Run view to display it
and click the Run button to launch the execution
of your Route. You can also press F6 to execute
it.RESULT: The service is successfully started. You can access it from
a Web browser using the service endpoint URL. The customer information is shown in
the browser.
Building the service consumer Route
This Route will consume the REST service that is built in the provider
Route.
Arranging the flow of the message

-
From the Palette, drag and drop
a cTimer, a cREST, and a cLog component onto
the design workspace. -
Link the cTimer, cREST and cLog
using the Row > Route connection. - Label the components for better identification of their roles.
Configuring how the message is processed
-
Double-click the cTimer
component to display its Basic settings
view in the Component tab. -
In the Repeat field, enter
1 to generate the message exchange one time. Keep the
default settings of the other options. -
Double-click the cREST
component to display its Basic settings
view in the Component tab. -
This cREST component will
consume the REST service built in the provider Route.In the Endpoint field, type
in the URL of the service, “http://localhost:8040/services/customers” in this example.Select Manual from the
Type list. In the Relative Path field, enter constant(“”). Select GET in the
HTTP Method list. Keep the default
settings of the other options. -
Keep the default settings of the cLog component to log the message exchanges.
-
Press Ctrl+S to save your
route.
Executing the Route
-
Click the Code tab at the
bottom of the design workspace to have a look at the generated code.As shown in the code, the Route is builtfrom
cTimer_1
. TheHTTP_PATH
,HTTP_METHOD
, andACCEPT_CONTENT_TYPE
are set incREST_1
. The message is then routed tocLog_1
. -
Click the Run view to display it
and click the Run button to launch the execution
of your Route. You can also press F6 to execute
it.RESULT: The customers information is displayed in the
console.