Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Binding ModeDescription

off

Binding is turned off. This is the default option.

auto

Binding is enabled and Camel is relaxed and support json, xml or both if the needed data formats are included in the classpath. Notice that if for example camel-jaxb is not on the classpath, then XML binding is not enabled.

json

Binding to/from json is enabled, and requires a json capabile data format on the classpath. By default Camel will use json-jackson as the data format. See the INFO box below for more details.

xml

Binding to/from xml is enabled, and requires camel-jaxb on the classpath. See the INFO box below for more details.

json_xml

Biding to/from json and xml is enabled and requires both data formats to be on the classpath. See the INFO box below for more details.

Tip

From Camel 2.14.1 onwards when using camel-jaxb for xml bindings, then you can use the option mustBeJAXBElement to relax the output message body must be a class with JAXB annotations. You can use this in situations where the message body is already in XML format, and you want to use the message body as-is as the output type. If that is the case, then set the dataFormatProperty option mustBeJAXBElement to false value.

...

Info

From Camel 2.16.3 onwards the binding from POJO to JSon/JAXB will only happen if the content-type header includes the word json or xml representatively. This allows you to specify a custom content-type if the message body should not attempt to be marshalled using the binding. For example if the message body is a custom binary payload etc.

To use binding you must include the necessary data formats on the classpath, such as camel-jaxb and/or camel-jackson. And then enable the binding mode. You can configure the binding mode globally on the rest configuration, and then override per rest service as well.

To enable binding you configure this in Java DSL as shown below

...