Skip to content

dscope-io/dscope-camel-ubl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camel UBL Component

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.

What It Does

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:

  • formattedOutput
  • useSchema
  • schemaLocation
  • noNamespaceSchemaLocation
  • indentString
  • charset

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.

Endpoint Reference

Required Parameters

Parameter Description
methodType Operation type: marshal or unmarshal
documentType UBL document type such as invoice, creditNote, or order

Common Parameters

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

Example Usage

Unmarshal UBL XML

from("file:inbox")
	.to("ubl:unmarshal?documentType=invoice&type=xml");

Marshal a JAXB Object Back to XML

from("direct:invoice")
	.to("ubl:marshal?documentType=invoice&type=xml&formattedOutput=true");

Round-Trip Example

The integration tests cover a full XML round trip for both invoice and creditNote documents using the sample files in src/test/resources/ubl/.

Build and Test

This project targets Java 21 and uses Maven.

mvn clean test
mvn clean install

Karavan Metadata

Karavan 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:java

This writes one JSON file per supported UBL 2.1 document type plus a shared model-labels.json file for field labels.

Project Structure

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

Notes

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

About

Apache Camel UBL 2.1 Component

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages