Name

Unmarshal — Converts the message data received from the wire into a format that Apache Camel processors can consume

Usage

The Unmarshal pattern uses Apache Camel's pluggable data format mechanism to convert messages into a format appropriate for processing by Apache Camel.

The Unmarshal pattern can be placed anywhere in the body of a route. However, it is typically placed after endpoints that receive the message.

Properties

Table 80 describes the properties you can specify using the properties editor.

Table 80. Unmarshal Properties

NameDescription
Data Format Type

Specifies the data type to which the data will be unmarshalled. For data formats that require configuration, the format's tab provides the property fields to configure the marshaller.

Because the GZip, Serialization, String, and Zip data formats are part of the Camel core, you need not add dependencies for them in your Mavenpom.xml file to use them. However, to use any of the other supported data formats, you must add a dependency on the component that implements the data format (for example, camel-protobuf, camel-xmlbeans, camel-flatpack, and so on) in your Mavenpom.xml file.

  • avro— Unmarshals Apache Avro binary data, formatted using a user-supplied schema, into Java Objects

  • beanio— Unmarshals flat data structures, formatted according to user-defined mappings, into Java Objects

  • bindy— Unmarshals flat data structures to Java Objects

  • castor—Unmarshals XML to Java Objects

  • crypto—Unmarshals encrypted cyphertext to Java Objects

  • csv—Unmarshals csv data to Java Objects

  • custom—Unmarshals a custom data format implemented using the DataFormat interface to Java Objects

  • flatpack—Unmarshals fixed-width or delimited text messages to Java Objects

  • gzip—Unmarshals gzipped compressed messages to uncompressed messages

  • hl7—Unmarshals byte streams to HL7 HAPI message objects

  • jaxb—Unmarshals XML to Java Objects

  • jibx—Unmarshals XML to Java Objects using the JiBX library

  • json—Unmarshals JSON to Java Objects

  • pgp—Unmarshals encrypted cyphertext to Java Objects

  • protobuf—Unmarshals Protocol Buffers format (Google's data exchange format) to Java Objects

  • rss—Unmarshals ROME SyndFeed messages to XML String messages

  • secureXML—Unmarshals encrypted XML to plain XML. This data format works at the document, element, and element content levels (including simultaneous, multinode encryption using XPath).

  • serialization—Unmarshals a binary blob to Java Objects using the standard Java serialization mechanism

  • soapjaxb—Unmarshals a SOAP message to a tree of Java Objects using JAXB and JAX-WS annotations

  • string—Unmarshals XML or text-based messages to String Objects

  • syslog—Unmarshals Java String Objects to RFC3164 message format

  • tidyMarkup—Unmarshals untidy HTML to well-formed HTML

  • xmlbeans—Unmarshals Java objects to XML using the XmlBeans library

  • xmljson—Unmarshals json directly to XML

  • xstream—Unmarshals Java objects to XML using the XStream library

  • zip—Unmarshals zip compressed messages to uncompressed messages

Inherit Error Handler Specifies whether the node should use the error handler configured for the route. The default is Disabled.
Ref Specifies a reference to a Spring bean configuring the Apache Camel data format to which the message body is unmarshalled.
Id Specifies a unique identifier for the endpoint. The Id can be used to refer to the endpoint in the Camel XML file.
Description Specifies a text description for the node. This description is included in the generated XML file, but it is informational only. It is not used by Apache Camel.

avro

Table 81 describes the properties needed to configure the avro unmarshaller.

Table 81. avro Properties

NameDescription
Instance Class Name Specifies the name of the instance class to use for unmarshalling. This is the class defined by your schema .apache.camel.dataformat.avro.<nameOfInstanceClass>.

beanio

Table 82 describes the properties needed to configure the beanio unmarshaller.

Table 82. beanio Properties

NameDescription
Encoding

Specifies the charset to use. The default is platform-specific.

Ignore Invalid Records

Species whether to ignore invalid records. The default is false.

Ignore Unexpected Records Species whether to ignore invalid records. The default is false.
Ignore Unidentified Records Species whether to ignore invalid records. The default is false.
Mapping Specifies the BeanIO mapping.xml file to use. By default, this file is loaded from the classpath, but you can add one of the prefixes—file:, http:, or classpath:—to specify the location from which to load this file.
Stream Name Specifies the name of the stream to use.

bindy

Table 83 describes the properties needed to configure the bindy unmarshaller.

Table 83. bindy Properties

NameDescription
Class Type

Specifies a fully qualified class name that explicitly defines the type to use for unmarshalling. For example, you might enter com.mycompany.MyOrder

You must use either this property or Packages, but not both.

Locale

Species the language name of the locale whose date and number format will be used. If not specified, the unmarshaller determines and uses the formatting of a default language name. Valid values are the two-letter abbreviation of the language name, in lower case. For example,

  • ar—Arabic

  • es—Castilian Spanish

  • da—Danish

  • en—English

  • fr—French

  • jp—Japanese

For an exhaustive list of language names, see Codes for the Representation of Names of Languages

Packages

Specifies the packages to use for unmarshalling. A package contains a defined model with required annotations properly associated for each class in the model. For example, you might enter com.mycompany.

When specifying multiple packages, separate them with a comma (,).

You must use either this property or Class Type, but not both.

Type Specifies the field type. Select Csv (comma-separated value fields), Fixed (fixed-length records), or KeyValue (key/value pair fields).

castor

Table 84 describes the properties needed to configure the castor unmarshaller.

Table 84. castor Properties

NameDescription
Classes Specifies additional classes to add to the Castor XmlContext. Enter the fully qualified path. When specifying multiple classes, separate them with a comma (,).
Encoding Specifies the encoding to use when unmarshalling XML to an Object. Default is UTF-8.
Mapping File Specifies the path to the Castor mapping file to load from the classpath.
Packages Specifies any additional packages to add to the Castor XmlContext. Enter the fully qualified path. When specifying multiple packages, separate them with a comma (,).

crypto

Table 85 describes the properties needed to configure the crypto unmarshaller.

Table 85. crypto Properties

NameDescription
Algorithm Specifies the name of the JCE cryptographic algorithm to use. Default is DES/CBC/PKCS5Padding.
Algorithm Parameter Ref Reference to the JCE AlgorithmParameterSpec to use to initialize the cipher. Some crypto algorithms, particularly block algorithms, require initialization by an initial block of data, known as an Initialization Vector. The JCE passes the Initialization Vector to the cipher as an AlgorithmParameterSpec. Select from the list of available options.
Buffersize Specifies the size, in bytes, of the buffer used in the signature process.
Crypto Provider Specifies the name of the JCE Security Provider to use. For options, see Java Cryptography Architecture; Sun Providers Documentation.
Init Vector Ref Reference to a byte array containing the Initialization Vector to use to initialize the cipher. Select from the list of available options.
Inline Enables inlining the configured Initialization Vector into the encrypted data stream.
Key Ref Specifies the value of the keyref attribute within the <dataFormats> element in a Spring configuration. For example, <crypto id="basic" algorithm="DES" keyref="desKey" />. Select from the list of available options.
Mac Algorithm Specifies the algorithm to use to create the Hash-based Message Authentication. Default is HmacSHA1. For more options, see Java Standard Names Reference.
Should Append HMAC Enables calculating and appending a Message Authentication Code to the decrypted data.

csv

Table 86 describes the properties needed to configure the csv unmarshaller.

Table 86. csv Properties

NameDescription
Config Ref Reference to a custom CSVConfig object.
Delimiter Specifies the character to use to separate the fields in a csv record. Default is , (comma). Valid values are any single character, such as ., |, ;, #, and so on.
Strategy Ref Reference to a custom CSVStrategy.

custom

Table 87 describes the properties needed to configure the custom unmarshaller.

Table 87. custom Properties

NameDescription
Ref Reference to the file that implements your custom data format using the DataFormat interface.

jaxb

Table 88 describes the properties needed to configure the jaxb unmarshaller.

Table 88. jaxb Properties

NameDescription
Context Path Specifies the context path for the jaxb data format. For example, org.apache.camel.example
Encoding

Specifies the encoding to use when unmarshalling data. Valid values include:

  • ISO-8859-1

  • US-ASCII

  • UTF-8

With no value specified, Red Hat Fuse IDE defaults to the encoding used by JAXB.

Filter Non XML Chars Enables the filtering of non XML characters during marshalling such that the marshaller replaces any non XML characters it encounters with the string " ". Otherwise, when it encounters a non XML character, the marshaller throws an exception.
Fragment Enables the marshaller's FRAGMENT encoding property, which prevents the marshaller from generating the XML declaration. Enable this property in conjunction with setting Part Class and Part Namespace to perform partial marshalling on only a fragment of the XML tree.
Ignore JAXBElement Disables the ignoreJAXBElement property so that the unmarshaller returns the JAXBElement object from the body of the unmarshalled message, instead of the value of the element instance (default behavior).
Part Class Specifies the uri of the class within the XML tree that you want to marshal, leaving all other classes in the tree as is. Set this property in conjunction with Fragment and Part Namespace to perform partial marshalling on only a fragment of the XML tree.
Part Namespace Specifies the Qname of the destination namespace.
Pretty Print Enables pretty printing, which adds white space as needed to tidy up the resulting XML for easy reading.

json

Table 89 describes the properties needed to configure the json unmarshaller.

Table 89. json Properties

NameDescription
Library Specifies the library to use for unmarshalling. Select either XStream or Jackson from the drop-down list. Default is XStream.
Pretty Print Enables pretty printing, which adds white space as needed to tidy up the resulting XML for easy reading.
Unmarshal Type Name Specifies the class type to use when unmarshalling; for example org.apache.camel.component.jackson.<typeName>. Defaults to using a map-based type. You can define a custom type to use with org.codehaus.jackson.map.OblectMapper.

pgp

Table 90 describes the properties needed to configure the pgp unmarshaller.

Table 90. pgp Properties

NameDescription
Armored Specifies whether the encrypted file was encoded using base64. The default is Disabled.
Integrity Specifies whether the encrypted file contains an integrity check sign. The default is Enabled.
Key File Name Specifies the name of the keyring file that contains the private keys to use to decrypt the data. This file must be accessible as classpathresource; for example, org/apache/camel/component/crypto/secring.gpg.
Key User Id Specifies the user id of the key in the pgp keyring that was used for encryption.
Password Specifies the password to use for opening the private key. This password is not used for encryption.

protobuf

Table 91 describes the properties needed to configure the protobuf unmarshaller.

Table 91. protobuf Properties

NameDescription
Instance Class Specifies the name of the instance class to use. This is one of the classes generated when you compiled your .proto file. Include the builder generated in the uri; for example, org.apache.camel.dataformat.protobuf.generated.<nameOfInstanceClass>.

secureXML

Table 92 describes the properties needed to configure the secureXML unmarshaller.

Table 92. secureXML Properties

NameDescription
Key Cipher Algorithm [a]

Specifies the cipher algorithm to use to decrypt the asymmetric key. Default is null. Valid values are:

  • XMLCipher.RSA_v1dot5

  • XMLCipher.RSA_OAEP

Asymmetric key decryption is enabled when either this property is set, or the Recipient Key Alias property is set.

Key Or Trust Store Parameters Id [a] Specifies the ID of the configuration options to use to create and load a keyStore instance that represents the recipient's keyStore, when performing asymmetric key decryption.
Key Password Specifies the password to use for retrieving the private key from the keystore, when performing asymmetric decryption.
Pass Phrase Specifies a string of alphanumeric characters to use as the passphrase for unmarshalling the message into regular text. The passphrase must be appropriate for the selected decryption algorithm. if not, the unmarshaller throws an exception. When no phrase is specified, the unmarshaller generates and uses a default passphrase.
Recipient Key Alias [a] Specifies the key alias to use for retrieving the recipient's public or private key from a KeyStore when performing asymmetric key encryption.
Secure Tag Specifies the XPath reference to the XML element to decrypt. If left blank, the entire XML message is decrypted.
XML Cipher Algorithm

Specifies the cipher algorithm to use for decrypting message content. Valid values are:

  • XMLCipher.TRIPLIDES [Default]

  • XMLCipher.AES_128

  • XMLCipher.AES_192

  • XMLCipher.AES_256

[a] Used for asymmetric key encryption


soapjaxb

Table 93 describes the properties needed to configure the soapjaxb unmarshaller.

Table 93. soapjaxb Properties

NameDescription
Context Path Specifies the path of the package to use for initializing the JAXB context.
Element Name Strategy Ref Selects the bean reference to the element name and its namespace within the body of the soap message.
Encoding

Specifies the encoding to use when unmarshalling data. Valid values include:

  • ISO-8859-1

  • US-ASCII

  • UTF-8

With no value specified, Red Hat Fuse IDE defaults to the encoding used by JAXB.

Version Specifies the version of soap to use. Options are 1.1 or 1.2; the default is 1.1.

string

Table 94 describes the properties needed to configure the string unmarshaller.

Table 94. string Properties

NameDescription
Charset

Specifies the character set to use for encoding. Valid values include:

  • ISO-8859-1

  • US-ASCII

  • UTF-8

With no value specified, Red Hat Fuse IDE defaults to the encoding used by the platform.


tidyMarkup

Table 95 describes the properties needed to configure the tidyMarkup unmarshaller.

Table 95. tidyMarkup Properties

NameDescription
Data Object Type Name Specifies the type of Object the unmarshaller outputs. Valid values are String and org.w3c.dom.Node.

XmlBeans

Table 96 describes the properties needed to configure the XmlBeans unmarshaller.

Table 96. XmlBeans Properties

NameDescription
Pretty Print Enables pretty printing, which adds white space as needed to tidy up the input XML for easy reading.

Xmljson

Table 97 describes the properties needed to configure the xmljson unmarshaller.

[Note]Note

An asterisk (*) to the right of a property name (unmarshaller properties only) indicates that the default value for that property is set by json-lib, not by the code of the data format.

Table 97. xmljson Properties

NameDescription
Array Name *

Specifies the name of the top-level XML element. The default is 'a'

For example, [1,2,3] is converted to <a><e>1</e><e>2</e><e>3</e><a> by default. By setting this property or Root Name, you can change the name of element 'a'.

Element Name *

Specifies the name of the XML element that represents each array element. The default is 'e'.

Encoding *

Specifies the encoding for the call to the XMLSerializer.write()method, so it's used only when generating XML.

Expandable Properties

Specifies expandable properties that alter the way JSON array elements are converted to XML. Using expandable properties, json array elements are converted to XML as a sequence of repetitive XML elements with the local name equal to the json key.

For example, if number is set as an expandable property, the array {number:1,2,3}, normally converted to <number>:<e>1</e><e>2</e><e>3</e></number>, will instead be converted to <number>1</number><number>2</number><number>3</number>.

Force Top Level Object

Applies to marshalling only.

Namespace Lenient *

Specifies whether to tolerate incomplete namespace prefixes. The default is false.

In most cases, json-lib automatically changes this property at runtime to match the processing.

Remove Namespace Prefixes

Applies to marshalling only.

Root Name *

Specifies the name of the top-level element when converting any JSON construct (object, array, null) to XML.

If not set, json-lib uses arrayName or objectName (default value of'o').

If set to 'root', the JSON string {'x':'value1','y':'value2'} is converted to <root><x>value1</x><y>value2</y></root>; otherwise, the 'root' element would be named 'o'.

Skip Namespaces

Applies to marshalling only.

Skip Whitespace Applies to marshalling only.
Trim Spaces Applies to marshalling only.
Type Hints

Specifies whether to add type hints to the resulting XML to aid conversion back to JSON. The default is YES.

Valid values are:

  • YES—enable type hints, prefixed with json_

  • NO—disable type hints

  • WITH_PREFIX—enable type hints, with no prefix


zip

Table 98 describes the properties needed to configure the zip unmarshaller.

Table 98. zip Properties

NameDescription
Compression Level

Not Applicable.


Related topics

Adding beans and configuration