2.29. Processing a D03B UN/EDIFACT Message Interchange
Fuse 6 is no longer supportedAs of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.
2.29. Processing a D03B UN/EDIFACT Message Interchange
To process a D03B UN/EDIFACT message interchange, follow the example below:
Reading:
// Create an instance of the EJC generated factory class... cache this and reuse !!!
D03BInterchangeFactory factory = D03BInterchangeFactory.getInstance();
// Deserialize the UN/EDIFACT interchange stream to Java...
UNEdifactInterchange interchange = factory.fromUNEdifact(ediInStream);
// Need to test which interchange syntax version. Supports v4.1 at the moment...
if(interchange instanceof UNEdifactInterchange41) {
UNEdifactInterchange41 interchange41 = (UNEdifactInterchange41) interchange;
for(UNEdifactMessage41 message : interchange41.getMessages()) {
// Process the messages...
Object messageObj = message.getMessage();
if(messageObj instanceof Invoic) {
// It's an INVOIC message....
Invoic invoic = (Invoic) messageObj;
ItemDescription itemDescription = invoic.getItemDescription();
// etc etc....
} else if(messageObj instanceof Cuscar) {
// It's a CUSCAR message...
} else if(etc etc etc...) {
// etc etc etc...
}
}
}
Writing:
factory.toUNEdifact(interchange, ediOutStream);
Reading:
// Create an instance of the EJC generated factory class... cache this and reuse !!!
D03BInterchangeFactory factory = D03BInterchangeFactory.getInstance();
// Deserialize the UN/EDIFACT interchange stream to Java...
UNEdifactInterchange interchange = factory.fromUNEdifact(ediInStream);
// Need to test which interchange syntax version. Supports v4.1 at the moment...
if(interchange instanceof UNEdifactInterchange41) {
UNEdifactInterchange41 interchange41 = (UNEdifactInterchange41) interchange;
for(UNEdifactMessage41 message : interchange41.getMessages()) {
// Process the messages...
Object messageObj = message.getMessage();
if(messageObj instanceof Invoic) {
// It's an INVOIC message....
Invoic invoic = (Invoic) messageObj;
ItemDescription itemDescription = invoic.getItemDescription();
// etc etc....
} else if(messageObj instanceof Cuscar) {
// It's a CUSCAR message...
} else if(etc etc etc...) {
// etc etc etc...
}
}
}
Writing:
factory.toUNEdifact(interchange, ediOutStream);
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Use Maven to add the ability to process a D03B message interchange by adding the binding dependency for that directory (you can also use pre-generated UN/EDIFACT Java object models distributed via the MavenSNAPSHOT and Central repositories):
We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.
Making open source more inclusive
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.
About Red Hat
We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.