Apache Camel component for working with UBL 2.1 documents. It supports XML marshal and unmarshal operations for the document types exposed by ph-ubl21, including common payloads such as invoice, creditNote, and order.
This component provides a Camel endpoint with a simple operation-based syntax:
ubl:marshal
ubl:unmarshal
It can work with either XML or DOM payloads and includes the following marshalling options:
formattedOutputuseSchemaschemaLocationnoNamespaceSchemaLocationindentStringcharset
The producer resolves options from the endpoint first and then falls back to exchange headers, which makes it easy to override document behavior in routes.
| Parameter | Description |
|---|---|
methodType |
Operation type: marshal or unmarshal |
documentType |
UBL document type such as invoice, creditNote, or order |
| Parameter | Allowed Values | Description |
|---|---|---|
type |
xml, dom |
Payload type used for marshal or unmarshal |
formattedOutput |
true, false |
Enable pretty-printed XML output |
useSchema |
true, false |
Enable schema-aware marshalling or unmarshalling |
schemaLocation |
string | Schema location written to marshalled XML |
noNamespaceSchemaLocation |
string | No-namespace schema location written to marshalled XML |
indentString |
string | Indentation string used for formatted output |
charset |
string | Charset used when marshalling XML |
from("file:inbox")
.to("ubl:unmarshal?documentType=invoice&type=xml");from("direct:invoice")
.to("ubl:marshal?documentType=invoice&type=xml&formattedOutput=true");The integration tests cover a full XML round trip for both invoice and creditNote documents using the sample files in src/test/resources/ubl/.
This project targets Java 21 and uses Maven.
mvn clean testmvn clean installKaravan metadata is generated in two parts:
- Component metadata is generated automatically by Camel into
src/generated/resources/META-INF/io/dscope/camel/ubl/ubl.json - Model metadata for UBL document types is generated under
src/main/resources/karavan/metadata/model/
To generate the Karavan model metadata, run:
mvn -Pkaravan-metadata compile exec:javaThis writes one JSON file per supported UBL 2.1 document type plus a shared model-labels.json file for field labels.
src/main/java/io/dscope/camel/ubl/ Camel component, endpoint, and producer implementation
src/main/java/io/dscope/tools/karavan/ Karavan metadata generator
src/main/resources/karavan/metadata/ Generated Karavan model metadata
src/test/resources/ubl/ Sample UBL XML documents used in integration tests
- The component currently focuses on producer-side marshal and unmarshal support.
- The generated Karavan metadata covers all 65 UBL 2.1 document types exposed by
ph-ubl21.