July 30, 2023

cConvertBodyTo – Docs for ESB ESB 7.x


Converts the message body to the given class type.

cConvertBodyTo Standard properties

These properties are used to configure cConvertBodyTo running in the Standard Job framework.

The Standard
cConvertBodyTo component belongs to the Transformation family.

Basic settings

Target Class Name

Enter the name of the class type that you want to convert the
message body to.


Usage rule

cConvertBodyTo is used as a
middle component in a Route.



Converting the body of an XML file into an

This scenario applies only to Talend Open Studio for ESB, Talend Data Services Platform and Talend Data Fabric.

In this scenario, a cConvertBodyTo component is used
to convert the body of an XML file into an org.w3c.dom.Document.class. Then a cBean component imports the org.w3c.dom.Document class,
checks its content and prints out the root element name and the content of each
category element.

The XML file is as follows:

Creating a Bean

  1. From the repository tree view, expand the Code node and right click the Beans node. In the contextual menu, select Create Bean.


  2. The New Bean wizard opens. In the Name field, type in a name for the bean, for
    example, PrintConvertToBean. Click Finish to close the wizard.


  3. Enter the following code in the design workspace.

  4. Press Ctrl+S to save your bean.

For more information about creating and using Java Beans, see
Talend Studio User

Dropping and linking the components

  1. Drag and drop a cFile, a cConvertBodyTo, a cBean and a cBeanRegister
    from the Palette onto the workspace.

  2. Link the cFile, cConvertBodyTo and cBean
    using the Row > Route connection as shown above.
  3. Label the components to better identify their functionality.

Configuring the components

  1. Double-click the cFile component to open
    its Basic settings view in the Component tab.


  2. In the Path field, enter or browse to the
    path to the source XML file.

    If the source file folder contains more than one file, enter the name of
    the XML file of interest in the FileName
    field, and leave the other parameters as they are.
  3. Double-click the cConvertBodyTo component
    to open its Basic settings view in the
    Component tab.


  4. In the Target Class Name field, enter
    your target class name, org.w3c.dom.Document.class in this scenario.
  5. Double-click the cBeanRegister component to open its Basic
    view in the Component


  6. In the Id field, enter

    Select the Simple option and in the
    Class Name field, enter the name of the
    bean to be invoked, beans.PrintConvertToBean in this scenario.
  7. Double-click the cBean component to open
    its Basic settings view in the Component tab.

  8. Select Reference and in the Id field, enter "bean" to call the
    bean that is registered by the cBeanRegister.
  9. 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 check the generated code.


    As shown above, the message from the endpoint
    Read_message_cFile_1 has its body converted to
    org.w3c.dom.Document.class by
    cConvertBodyTo_1, and then processed by bean
    invoked by cBean_1.
  2. Press F6 to execute the Route.

    RESULT: The root element name and the contents of the category elements are displayed.

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