我想讀取EDI消息並將其轉換爲Java對象,但我以下面的異常結束。EDI流到Java對象轉換的異常
線程「main」中的異常org.milyn.SmooksException:未能過濾 源。在 org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:97) 在 org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:64) 在org.milyn.Smooks._filter (Smooks.java:526)at org.milyn.Smooks.filterSource(Smooks.java:482)at org.milyn.Smooks.filterSource(Smooks.java:456)at org.milyn.edi.unedifact.d97a .D97AInterchangeFactory.fromUNEdifact在 org.milyn.edi.unedifact.d97a.D97AInterchangeFactory.fromUNEdifact(D97AInterchangeFactory.java:40)(D97AInterchangeFactory.java:58) 在com.ibm.gpohub.edi.common.SmooksSample.main( SmooksSample.java:18) 引起:org.milyn.edisax.EDIParseException:EDI消息處理 失敗[ORDRSP] [D:97A:UN]。段[FTX],字段4(TEXT_LITERAL), 組件1(Free_text _-_-1)預計包含一個值。目前 處 org.milyn.edisax.EDIParser.mapField(EDIParser.java:636)段號6. org.milyn.edisax.EDIParser.mapComponent(EDIParser.java:687)在 org.milyn.edisax .EDIParser.mapFields(EDIParser.java:606)在 org.milyn.edisax.EDIParser.mapSegment(EDIParser.java:564)在 org.milyn.edisax.EDIParser.mapSegments(EDIParser.java:535)在 組織.milyn.edisax.EDIParser.mapSegments(EDIParser.java:453)at org.milyn.edisax.EDIParser.parse(EDIParser.java:428)at org.milyn.edisax.EDIParser.parse(EDIParser.java:410 )at org.milyn.edisax.unedifact.handlers.UNHHandler.process(UNHHandler.java:97) at org.milyn.edisax.unedif act.handlers.UNGHandler.process(UNGHandler.java:58) 在 org.milyn.edisax.unedifact.handlers.UNBHandler.process(UNBHandler.java:75) 在 org.milyn.edisax.unedifact.UNEdifactInterchangeParser。解析(UNEdifactInterchangeParser.java:113) at org.milyn.smooks.edi.unedifact.UNEdifactReader.parse(UNEdifactReader.java:75) at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76 )在 org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86) ... 7更
這裏是代碼片段:
D97AInterchangeFactory d97InterChangeFactory = (D97AInterchangeFactory)SmooksFactoryImpl.D97A_FACTORY.getInstance();
InputStream ediSource = new FileInputStream("C:\\EDIFACT_MSG.txt");
UNEdifactInterchange interchange = d97InterChangeFactory.fromUNEdifact(ediSource);
if(interchange instanceof UNEdifactInterchange41){
List<UNEdifactMessage41> messages = ((UNEdifactInterchange41) interchange).getMessages();
for(UNEdifactMessage41 msg:messages){
System.out.println(msg.toString());
}
}
EDIMessage:
UNA:+? UNB + UNOC:3 + 662424795TEST:16 + IBMEDIID:ZZ + 160330:1416 + IG-62779496 UNG + ORDRSP + 662424795TEST:16 + IBMEDIID:ZZ + 160330:1420 + FG-34160863 + UN + D:97A UNH + 80534414 + ORDRSP:D:97A:UN BGM + 231 + 20160330 + 4 DTM + 69:20150501150000UTC +12:304 FTX + SSR +++:空白FTX + AAR ++ ST FTX + COI +++ CLW FTX + PRI ++ 8 FTX + DEL ++ 06 FTX + CUR +++將所有項目合併爲一個 box FTX + DIN +++在發貨前打電話給客戶 FTX + PRD +++ 1:1:PC01 FTX + AAP +++ 900:接受RFF + PC:20AMS67000 RFF + SE:PC01K33E RFF + SZ:ND RFF + ABO:Y RFF + CO:IBM1234501 DTM + 4:20150501010101UTC?+12:304 RFF + ACW:CASE_12345 RFF + ADG:Y RFF + ACH:Y RFF + ZOD:order_desk01 RFF + ZSD:IBM RFF + ZPD:30006672 RFF + ZCS:空白 RFF + ZZZ NAD + SE + 300IBM NAD + BY + US00000001 ++可口可樂:CA + 9/F:841 WEBSTER ST:壓力3:空白+舊金山++ 94117 +美國CTA + PD +:約旦 Surzyn [email protected]: EM COM + 6508624654:TE NAD + OY + US00000001 ++ IBM 現場服務:CA + 9/F:900 WEBSTER ST:壓力3:空白+ SAN FRANCISCO ++ 94117 +美國CTA + CR +:Will Smith COM + @ ibm.com:EM COM + 6508624654:TE LIN + 10 PIA + 5 + 04X6076 IMD + F ++ ::: KEYBOARD NetVista 鍵盤(USB)數量+ 21:1:EA DTM + 69:20160610120000UTC?+12:304 FTX + OSI +++ INW FTX + LIN +++ ZSP1 FTX + AAP +++ 900:接受FTX + ZCT +++ STO從 DC到FSL RFF + ZSB:01 RFF + ZRO:Y RFF + ZOR:鍵盤很好條件 RFF + ZST:SOFT UNS + S UNT + 50 + 80534414 UNE + 1 + FG-34160863 UNZ + 1 + IG-62779496
任何人都可以指導我,我哪裏做錯了嗎? 在此先感謝。
是的,EDIFACT默認段結束符是'字符,在UNA段中指定。 – MikeRalphson