2.29. Processing a D03B UN/EDIFACT Message Interchange
Fuse 6 is no longer supported
As 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):