iso 8583解包错误字段123数组索引超出范围

时间:2014-11-05 07:55:14

标签: java iso jpos

我正在使用JPOS来打包和解包ISO消息,消息的打包很好,当我收到以下回复时

1210E030000002000020000000000400002807110457626000026000000052220140909134530000001812UU2411906554003TCB48520141026|20141026|D|UG|142465.75|Interest Paid||20991780.75^20140930|20140930|D|UG|164383.55|Interest Paid||20849315^20140831|20140831|D|UG|169863.00|Interest Paid||20684931.45^20140731|20140731|D|UG|169863.00|Interest Paid||20515068.45^20140630|20140630|D|UG|164383.55|Interest Paid||20345205.45^20140531|20140531|D|UG|169863.00|Interest Paid||20180821.9^20140430|20140430|D|UG|10958.90|Interest Paid||20010958.9^20140429|20140429|D|UG|20000000.00|Deposit Created||20000000.00

当我尝试解压缩时,我收到以下错误:

error unpacking field 123
org.jpos.iso.ISOException: org.jpos.iso.IFA_LLLCHAR: Problem unpacking field 123 (java.lang.ArrayIndexOutOfBoundsException: 592)
    at org.jpos.iso.ISOStringFieldPackager.unpack(ISOStringFieldPackager.java:178)
org.jpos.iso.ISOException: org.jpos.iso.IFA_LLLCHAR: Problem unpacking field 123 (java.lang.ArrayIndexOutOfBoundsException: 592)
    at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:233)

2 个答案:

答案 0 :(得分:0)

这是我使用的代码

ISOMsg msg = new ISOMsg();

try {
    msg.setPackager(new GenericPackager("iso87ascii.xml"));
    msg.unpack(str.getBytes("UTF8"));

    msg.dump(System.out, "");
} catch (ISOException e) {
    e.printStackTrace();
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
}

如果您开始删除第一个字符,您将开始获得结果,如下所示:

str="210E030000002000020000000000400002807110457626000026000000052220140909134530000001812UU2411906554003TCB48520141026|20141026|D|UG|142465.75|Interest Paid||20991780.75^20140930|20140930|D|UG|164383.55|Interest Paid||20849315^20140831|20140831|D|UG|169863.00|Interest Paid||20684931.45^20140731|20140731|D|UG|169863.00|Interest Paid||20515068.45^20140630|20140630|D|UG|164383.55|Interest Paid||20345205.45^20140531|20140531|D|UG|169863.00|Interest Paid||20180821.9^20140430|20140430|D|UG|10958.90|Interest Paid||20010958.9^20140429|20140429|D|UG|20000000.00|Deposit Created||20000000.00";

输出:

<isomsg>
  <!-- org.jpos.iso.packager.GenericPackager[iso87ascii.xml] -->
  <field id="0" value="210E"/>
  <field id="7" value="0000000040"/>
  <field id="8" value="00028071"/>
  <field id="35" value="4576260000"/>
  <field id="55" value="00000052220140909134530000001812UU2411906554003TCB48520141026|20141026|D|UG|142465.75|Interest Paid||20991780.75^20140930|20140930|D|UG|164383.55|Interest Paid||20849315^20140831|20140831|D|UG|169863.00|Interest Paid||20684931.45^20140731|20140731|D|UG|169863."/>
</isomsg>

如果从str:

的开头删除'2'
<isomsg>
  <!-- org.jpos.iso.packager.GenericPackager[iso87ascii.xml] -->
  <field id="0" value="10E0"/>
  <field id="3" value="000000"/>
  <field id="4" value="040000280711"/>
  <field id="31" value="045762600"/>
  <field id="51" value="002"/>
</isomsg>

依旧......

如果您删除整个1210E,则会获得

<isomsg>
  <!-- org.jpos.iso.packager.GenericPackager[iso87ascii.xml] -->
  <field id="0" value="0300"/>
  <field id="19" value="000"/>
  <field id="39" value="04"/>
</isomsg>

我发现逻辑,因为它有iso39(响应)

我不确定这是否可以提供帮助,但它可以为您提供线索,

答案 1 :(得分:0)

我在这里得到了解决方案https://github.com/jpos/jPOS/blob/master/jpos/src/dist/cfg/packager/test-generic-validating-packager.xml这是一个包装问题。我使用了打包器,它工作正常。如果服务器端的打包器与客户端不同,则可能发生错误。