我正在尝试读取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(D97AInterchangeFactory.java:58) 在 org.milyn.edi.unedifact.d97a.D97AInterchangeFactory.fromUNEdifact(D97AInterchangeFactory.java:40) 在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)预计包含一个值。目前 在第6段 org.milyn.edisax.EDIParser.mapComponent(EDIParser.java:687)at at org.milyn.edisax.EDIParser.mapField(EDIParser.java:636)at at org.milyn.edisax.EDIParser.mapFields(EDIParser.java:606)at at org.milyn.edisax.EDIParser.mapSegment(EDIParser.java:564)at at org.milyn.edisax.EDIParser.mapSegments(EDIParser.java:535)at at org.milyn.edisax.EDIParser.mapSegments(EDIParser.java:453)at at org.milyn.edisax.EDIParser.parse(EDIParser.java:428)at at org.milyn.edisax.EDIParser.parse(EDIParser.java:410)at at org.milyn.edisax.unedifact.handlers.UNHHandler.process(UNHHandler.java:97) 在 org.milyn.edisax.unedifact.handlers.UNGHandler.process(UNGHandler.java:58) 在 org.milyn.edisax.unedifact.handlers.UNBHandler.process(UNBHandler.java:75) 在 org.milyn.edisax.unedifact.UNEdifactInterchangeParser.parse(UNEdifactInterchangeParser.java:113) 在 org.milyn.smooks.edi.unedifact.UNEdifactReader.parse(UNEdifactReader.java:75) 在org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76)at 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:联合国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 +++将所有项目合并为一个 盒子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 + 30001234 ++ IBM NAD + BY + US00000001 ++可口可乐:CA + 9 / F:841 WEBSTER ST:压力3:空白+旧金山++ 94117 +美国CTA + PD +:乔丹 Surzyn COM + Minako@DHL.com:EM COM + 6508624654:TE NAD + OY + US00000001 ++ IBM 现场服务:CA + 9 / F:900 WEBSTER ST:压力3:空白+ SAN FRANCISCO ++ 94117 + US CTA + CR +:Will Smith COM+Will@ibm.com:EM COM + 6508624654:TE LIN + 10 PIA + 5 + 04X6076 IMD + F ++ :::键盘NetVista 键盘(USB)QTY + 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
任何人都可以指导我,我做错了吗? 提前谢谢。
答案 0 :(得分:0)
这是因为EDIFACT消息格式不正确。在我收到正确的EDIFACT消息后,它会得到解决,如下所示。希望任何一个遇到类似问题的人都可以帮忙。 --thanks
UNA:+。? &#39; UNB + UNOC:3 + IBM:ZZZ + 662424795TEST:16 + 160330:1416 + 00000016086706 ++++ 1&#39; UNG + ORDRSP + IBM:ZZZ + 662424795TEST:16 + 160330:1420 + 00000000160867 + UN + d:97A&#39; UNH + 1 + ORDRSP:d:97A:UN&#39; BGM + 231 + 20160330 + 4&#39; DTM + 69:20160501150000UTC +12:304&#39; FTX + AAR ++ ER&#39; FTX + SSR +++ N:AM&#39; FTX + COI +++ CLW&#39; FTX + PRI ++ 8&#39; FTX + DEL ++ 04&#39; FTX + CUR +++将所有项目打包成 一盒&#39; FTX + DIN +++在发货前致电客户&#39; FTX + PRD +++ IBMDECK001 :: PC01&#39; FTX + AAP +++ 900:接受&#39; RFF + PC:20 AMS67000' RFF + SE:PC01K33E&#39; RFF + SZ:ND&#39; RFF + ABO:N&#39; RFF + CO:IBM1234501&#39; RFF + ACW:IBMCASE12301&#39; DTM + 4:20150501000000UTC 12:304&#39; NAD + SE + 30006672 ++ 3100001&#39; NAD + BY + US00000001 ++ CA:NEC Personal Computers,Ltd。+ 9 / F:841 WEBSTER ST:压力3 + SAN 北京时间++ 941171717 + US&#39; CTA + PD +:Jordan Surzyn&#39; COM+Minako@DHL.com:EM&#39; COM + 6508624654:TE&#39; NAD + OY + US00000001 ++ CA:NEC个人电脑, 有限公司+ 9 / F:841 WEBSTER ST:压力3 + SAN FRANCISCO ++ 941171717 + US&#39; CTA + CR +:Jordan Surzyn&#39; COM+Minako@DHL.com:EM&#39; COM + 6508624654:TE&#39; LIN + 20 +++ 1:10&#39; PIA + 5 + 04X6076&#39; IMD + F ++ :::键盘NetVista键盘 (USB)&#39; QTY + 21:1:EA&#39; DTM + 69:20160610120000UTC +12:304&#39; FTX + LIN +++ ZSP1&#39; FTX + AAP +++ 900:Accpet头&#39; FTX + OSI +++ INW&#39; FTX + BSC +++ KEYBOARD很好 条件&#39; RFF + SE:Y&#39; NAD + OY + 01 + SOFT&#39; UNS + S&#39; UNT + 41 + 1&#39; UNE + 1 + 00000000160867&#39; UNZ + 1 + 00000016086706&#39;