August 17, 2023

cCXFRS – Docs for ESB 5.x

cCXFRS

ccxfrs_icon32_white.png

cCXFRS properties

Component Family

Messaging

Function

cCXFRS provides integration with
Apache CXF for connecting to JAX-RS services hosted in CXF.

Purpose

cCXFRS is used to provide or
consume REST-ful Web services.

Basic settings

Endpoint

The service endpoint URL where the REST service is provided.

 

Type

Select which type you want to use to provide the REST service. Either Manual or resourceClass.

Manual: Determine the REST API mapping manually in the
table if cCXFRS is used as a
service provider, or set HTTP Method and other parameters if the
component is used as a service consumer.

resourceClass: Select this type to provide the
resource class which you want to export as the REST service.

 

REST API Mapping

This table appears when the Manual service type is
selected and cCXFRS is used as a
service provider.

Click [+] under the table to add as many rows as
needed to specify the HTTP request:

Output Flow: Specify the name of an output
flow.

HTTP Verb: Select a HTTP method from GET, POST, PUT,
DELETE, OPTIONS and HEAD in
the list.

URI pattern: Fill this field with the REST URI that
describes the resource.

Consumes: Select the format type of the consume
content that the component will use from XML
or JSON
, XML,
JSON, Form, Multipart,
and Any when HTTP Verb is POST
or PUT.

Produces: Select the format type of the produce
content that the component will use from XML
or JSON
, XML,
JSON, HTML, Any when
HTTP Verb is GET, POST, PUT or
DELETE.

Bean class: Set the bean class when the HTTP Verb is POST or PUT and the
consume content format is XML or
JSON
, XML or
JSON.

 

Resource Class

This field appears when the resourceClass service type
is selected. Enter the name of the resource class which you want to
export as the REST service.

 

Operation

This field appears when the resourceClass service type
is selected and cCXFRS is used as
the service consumer. Enter the name of the operation.

 

Relative Path

This field appears when the Manual service type is
selected and cCXFRS is used as the
service consumer. Enter the relative path of the REST server to be
invoked.

 

HTTP Method

This option appears when the Manual service type is
selected and cCXFRS is used as the
service consumer. Select a HTTP method fromGET, POST,
PUT, and DELETE in the list.

 

Content Type

This option appears when the Manual service type is
selected and cCXFRS is used as the
service consumer.

Select XML, JSON, or
FORM according to the media
type of the content to be uploaded to the server end. This list
appears only when you select the POST or PUT in the
HTTP Method list.

 

Accept Type

This field appears when the Manual service type is
selected and cCXFRS is used as the
service consumer.

Select the media type the client end is prepared to accept for the response from the
server end. Available options are XML, JSON, and
ANY. When ANY is selected, the response message can be of any
type and will be transformed into a string. This list does not
appear when you select the DELETE
method.

 

Response Class

This field appears when the Manual service type is
selected and the cCXFRS is used as
the service consumer. Enter the name of the response class.

 

Use Service Locator

Select this check box to enable the Service Locator. Specify the
service namespace and the service name in the corresponding
fields.

 

Use Service Activity Monitor

Select this check box to enable the Service Activity Monitor.

 

Use Authentication

Select this check box to enable the authentication option. Select
from SAML Token (ESB runtime only)
and HTTP Basic.

When the cCXFRS component is used as consumer, enter a
username and a password in the corresponding fields as required. To
enter the password, click the […]
button next to the password field, and then in the pop-up dialog box
enter the password between double quotes and click OK to save the settings.

 

Use Authorization

This option is only available if you subscribed to Talend
Enterprise ESB solutions. It appears when SAML
Token (ESB runtime only)
is selected in the Use Authentication list.

When the cCXFRS component is used as the service
provider, select this check box to enable authorization.

When the cCXFRS component is used as the service
consumer, select this check box to invoke authorized call and
specify the client’s role in the Role field.

 

Use Business Correlation

Select this check box to create a correlation ID in this
component.

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
Route.

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

cCXFRS can be a start component in a Route as the
service provider, or middle or end component as the service
consumer.

Limitation

Due to the license incompatibility, one or more JAR files required to use this component are
not provided. You can install these missing JAR files by clicking the Install button in the Basic settings view
of the Component tab. For more information, see the section
about how to configure the Studio of the Talend Installation and Upgrade Guide.

Scenario: Providing and consuming a REST service using cCXFRS

This scenario demonstrates how to use the cCXFRS component
to provide and consume a REST service. To do so, two Routes are built, a service
provider Route and a consumer Route.

Building the service provider Route

This Route provides a REST Web service which will be accessible for requests.

Dropping and linking the components

use_case_ccxfrs1.png
  1. From the Palette, drag and drop a cCXFRS, a cSetBody, a
    cLog and a cBeanRegister component onto the design workspace.

  2. Link the cCXFRS, cSetBody and cLog using the
    Row > Route connection.

  3. Label the components for better identification of their roles.

Configuring the components

  1. Double-click the cBeanRegister component
    to display its Basic settings view in the
    Component tab.

    use_case_ccxfrs2.png
  2. 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:

  3. Double-click the cCXFRS component to display its
    Basic settings view in the Component tab.

    use_case_ccxfrs3.png
  4. 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.

    use_case_ccxfrs4.png
  6. Select SIMPLE from the Dataformat list. In the Expression field, enter “ref:customers”
    to refer to the bean defined in the cBeanRegister component.

  7. Keep the default settings of the cLog
    component to log the message exchanges.

    use_case_ccxfrs5.png
  8. Press Ctrl+S to save your route.

Viewing code and executing the Route

  1. Click the Code tab at the bottom of the
    design workspace to have a look at the generated code.

    use_case_ccxfrs6.png

    As shown in the code, the Route is built from
    cCXFRS_1, set message body in cSetBody_1 and then
    to cLog_1.

  2. 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.

    use_case_ccxfrs7.png

Building the service consumer Route

This Route will consume the REST service that is built in the provider Route.

Dropping and linking the components

use_case_ccxfrs8.png
  1. From the Palette, drag and drop a
    cTimer, a cCXFRS, and a cLog
    component onto the design workspace.

  2. Link the cTimer, cCXFRS
    and cLog using the Row > Route
    connection.

  3. Label the components for better identification of their roles.

Configuring the components

  1. Double-click the cTimer component to display its
    Basic settings view in the Component tab.

    use_case_ccxfrs9.png
  2. In the Repeat field, enter 1 to
    generate the message exchange one time. Keep the default settings of the
    other options.

  3. Double-click the cCXFRS component to
    display its Basic settings view in the
    Component tab.

    use_case_ccxfrs10.png
  4. In the Endpoint field, type in the URL of the Web
    service built in the provider Route, “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.

  5. Keep the default settings of the cLog
    component to log the message exchanges.

    use_case_ccxfrs11.png
  6. Press Ctrl+S to save your route.

Viewing code and executing the Route

  1. Click the Code tab at the bottom of the
    design workspace to have a look at the generated code.

    use_case_ccxfrs12.png

    As shown in the code, the Route is built from
    cTimer_1. The HTTP_PATH, HTTP_METHOD,
    ACCEPT_CONTENT_TYPE, and
    CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS are set in
    cCXFRS_1. The message is then routed to
    cLog_1.

  2. 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.

    use_case_ccxfrs13.png

Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x