-
Language:
English
-
Language:
English
Red Hat Training
A Red Hat training course is available for Red Hat Fuse
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);
- 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 Maven
SNAPSHOT
andCentral
repositories):<dependency> <groupId>org.milyn.edi.unedifact</groupId> <artifactId>d03b-binding</artifactId> <version>v1.4</version> </dependency>