我使用以下代码:
import org.jpos.iso.ISOPackager;
import org.jpos.iso.packager.GenericPackager;
import org.jpos.iso.packager.ISO87BPackager;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
import org.junit.Assert;
public class Utils {
public static ISOMsg ParseIsoMessage(String hexMsg) throws ISOException {
// convert hex string to byte array
byte[] bmsg =ISOUtil.hex2byte(hexMsg);
ISOMsg mes = new ISOMsg();
// set packager, change ISO87BPackager for the matching one.
mes.setPackager(new GenericPackager("resources\\packager.xml"));
//unpack the message using the packager
mes.unpack(bmsg);
//dump the message to standar output
mes.dump(System.out, "");
return mes;
}
}
中的102个字段
packager.xml (
copy with iso87binary.xml with one change):
<isofield
id="102"
length="28"
name="ACCOUNT IDENTIFICATION 1"
class="org.jpos.iso.IFB_LLCHAR"/>
an error is issued:
org.jpos.iso.ISOException:org.jpos.iso.IFB_LLCHAR:问题拆包字段102(java.lang.ArrayIndexOutOfBoundsException:10187)拆包字段= 102,已消耗= 10187
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:340)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:468)
at Utils.ParseIsoMessage(Utils.java:17)
at TestHostToHost.test0100(TestHostToHost.java:122)
请帮助我找出问题所在。也许另一个类需要在打包程序中注册55个字段?我尝试了不同。 如何解决这个问题?
用于分析的字符串: 30313130F66032810EC3A200000000000701000019070133300400000000110000000000000010001234567890121216161120123456781829510222064300000006555444303739353633313830373739363937425A4E303052553435303039393233343233343533342020202020200032393038303032303539313930303133393536303131303030303030303030303800243831393030317A3835363031313030303030303030303038064306430042910A12073E49A98826FD3030711C861A84DA0000158003770C060000271000000190A534793E8E0B5CF617464E5F4143434F554E545F4944454E543117464E5F4143434F554E545F4944454E543217464E5F5452414E535F4445534352495054000085F053C1024204E31DC11B54504F5254414C2020202020202020202020202020202020202020E41381024401820513102800058306131028100454EA19FF0116D103543233D2024204D3034202D5D5024210D9025431
关于此数据的信息存储在此行中:
Message size 587
Message type 0100
P0002 PAN LEN=19 OFFS=21 '7013330040000000011'
P0003 Processing Code LEN=6 OFFS=31 '000000'
P0003-01 Transaction Type LEN=2 OFFS=31 '00'
P0003-02 Account Type (From) LEN=2 OFFS=32 '00'
P0003-03 Account Type (To) LEN=2 OFFS=33 '00'
P0004 Amount, Transaction LEN=12 OFFS=34 '000000001000'
P0006 Amount, Cardholder Billing LEN=12 OFFS=40 '123456789012'
P0007 Transmission Date and Time LEN=10 OFFS=46 '1127125301'
P0010 Conversion Rate, Cardholder Billing LEN=8 OFFS=51 '12345678'
P0011 Systems Trace Audit Number LEN=6 OFFS=55 '000082'
P0012 Time, Local Transaction LEN=6 OFFS=58 '125300'
P0013 Date, Local Transaction LEN=4 OFFS=61 '1127'
P0014 Date expiration LEN=4 OFFS=63 '2002'
P0018 Merchant Type LEN=4 OFFS=65 '1111'
P0019 Acq. Inst. Country Code LEN=3 OFFS=67 '222'
P0020 PAN Country Code LEN=3 OFFS=69 '643'
P0022 POS Entry Mode LEN=3 OFFS=71 '951'
P0023 Card Sequence Number LEN=3 OFFS=73 '000'
P0025 POS Condition Code LEN=2 OFFS=75 '00'
P0026 POS PIN Capture Code LEN=2 OFFS=76 '12'
P0028 Amount, Transaction Fee LEN=9 OFFS=77 '123456789'
P0032 Acquiring Inst. Ident Code LEN=6 OFFS=87 '555444'
P0033 Forwarding Inst. Ident. Code LEN=11 OFFS=91 '12345678901'
P0035 Track-2 Data LEN=37 OFFS=98 '7013330040000000011=70133300400000020'
P0037 Retrieval reference number LEN=12 OFFS=117 '511302068006'
(Wed Nov 27 2019 18:14:10.959000)
P0041 Card Acceptor Terminal Id LEN=8 OFFS=129 'RU450099'
P0042 Card Acceptor Ident. Code LEN=15 OFFS=137 '234234534 '
P0043 Card Acceptor Name/Location LEN=40 OFFS=152 'GPN >Arhagelsk RU'
P0045 Track-1 Data LEN=54 OFFS=193 'B4000001234567890^IVANOV/ABRAM^03101011123400567000000'
P0047 Proprietary Field 47 LEN=41 OFFS=249 '90800205918003101919001395601100000000008'
P0048 Proprietary Field 48 LEN=24 OFFS=292 '819001z85601100000000008'
P0049 Currency Code, Transaction LEN=3 OFFS=316 '643'
P0051 Currency Code, Cardholder Billing LEN=3 OFFS=318 '643'
P0055 Smart Card Specific Data LEN=99 OFFS=322 '9F3303E0F0C8950528000080009F37047EB5DF209F3602000182023C009C01009F1A0206439A031911279F02060000000010005F2A0206439F2701809F34034103029F101306010A03A430000B000000000003E0F34C860D9F2608B35C4C87CF835226'
P0055-9F33 Terminal Capabilities LEN=3 OFFS=325 'E0F0C8'
P0055-0095 TVR LEN=5 OFFS=330 '2800008000'
P0055-9F37 Unpredictable number LEN=4 OFFS=338 '7EB5DF20'
P0055-9F36 Application transaction counter LEN=2 OFFS=345 '0001'
P0055-0082 App interchange profile LEN=2 OFFS=349 '3C00'
P0055-009C Transaction Type LEN=1 OFFS=353 '00'
P0055-9F1A Terminal Country Code LEN=2 OFFS=357 '0643'
P0055-009A Transaction Date LEN=3 OFFS=361 '191127'
P0055-9F02 Amount, Authorised LEN=6 OFFS=367 '000000001000'
P0055-5F2A Transaction Currency Code LEN=2 OFFS=376 '0643'
P0055-9F27 Cryptogram info LEN=1 OFFS=381 '80'
P0055-9F34 CVM results LEN=3 OFFS=385 '410302'
P0055-9F10 Issuer application data LEN=19 OFFS=391 '06010A03A430000B000000000003E0F34C860D'
P0055-9F26 ARQC LEN=8 OFFS=413 'B35C4C87CF835226'
P0102 Account Identification-1 LEN=17 OFFS=429 'FN_ACCOUNT_IDENT1'
P0103 Account Identification-2 LEN=17 OFFS=447 'FN_ACCOUNT_IDENT2'
P0104 Transaction Description LEN=17 OFFS=465 'FN_TRANS_DESCRIPT'
P0112 Proprietary Field 112 LEN=88 OFFS=485 'F056C1024204E31DC11B54504F5254414C2020202020202020202020202020202020202020E41381024401820513102800058306131028100454EA1CFF0119D103543233D2034204D0D3034202D5D50442010D00D9025431'
F0 Local fleet data LEN=86 OFFS=487 'C1024204E31DC11B54504F5254414C2020202020202020202020202020202020202020E41381024401820513102800058306131028100454EA1CFF0119D103543233D2034204D0D3034202D5D50442010D00D9025431'
C1 Protocol Version LEN=2 OFFS=489 '4204'
E3 Vehicle And Driver info LEN=29 OFFS=493 'C11B54504F5254414C2020202020202020202020202020202020202020'
E4 POS Additional Info LEN=19 OFFS=524 '81024401820513102800058306131028100454'
EA Commodity Info LEN=28 OFFS=545 'FF0119D103543233D2034204D0D3034202D5D50442010D00D9025431'
FF01 LEN=25 OFFS=548
D1 Commodity Code LEN=3 OFFS=550 'T23'
D2 Quantity LEN=3 OFFS=555 '4204D0 (40000)'
D3 Price LEN=3 OFFS=560 '4202D5 (25000)'
D5 Cost LEN=4 OFFS=565 '42010D00 (100000)'
D9 Additional Data LEN=2 OFFS=571 'T1'
答案 0 :(得分:0)
显示的数据和打印的原始消息不匹配 原始消息未遵循所定义打包程序的格式。 该问题可能在字段102之前发生。
为了进行手动调试,您可以检查位图的位置并查看位置是否符合规范。
答案 1 :(得分:0)
我尝试使用iso-8583-packer library解压缩上述消息,该消息包含以下数据
<f name="Root">
<f name="MTI" val="0110" valHex="30313130"/>
<f name="Bitmap" bitSet="{1, 2, 3, 4, 6, 7, 10, 11, 19, 20, 23, 25, 32, 37, 38, 39, 41, 42, 47, 48, 49, 51, 55, 102, 103, 104, 112}">
<f name="PAN" fieldNum="2" val="1907013330040000000011"/>
<f name="Processing Code" fieldNum="3">
<f name="01 Transaction Type" val="00"/>
<f name="02 Account Type (From)" val="00"/>
<f name="03 Account Type (To)" val="00"/>
</f>
<f name="Amount, Transaction" fieldNum="4" val="000000001000"/>
<f name="Amount, Cardholder Billing" fieldNum="6" val="123456789012"/>
<f name="Transmission Date and Time" fieldNum="7" val="1216161120"/>
<f name="Conversion Rate, Cardholder Billing" fieldNum="10" val="12345678"/>
<f name="Systems Trace Audit Number" fieldNum="11" val="182951"/>
<f name="Acq. Inst. Country Code" fieldNum="19" val="222" valHex="0222"/>
<f name="PAN Country Code" fieldNum="20" val="643" valHex="0643"/>
<f name="Card Sequence Number" fieldNum="23" val="000" valHex="0000"/>
<f name="POS Condition Code" fieldNum="25" val="0006"/>
<f name="Acquiring Inst. Ident Code" fieldNum="32" val="555444"/>
<f name="Retrieval reference number" fieldNum="37" val="079563180779" valHex="303739353633313830373739"/>
<f name="Approval Code" fieldNum="38" val="697BZN" valHex="363937425A4E"/>
<f name="Action Code" fieldNum="39" val="00" valHex="3030"/>
<f name="Card Acceptor Terminal Id" fieldNum="41" val="RU450099" valHex="5255343530303939"/>
<f name="Card Acceptor Ident. Code" fieldNum="42" val="234234534 " valHex="323334323334353334202020202020"/>
<f name="Proprietary Field 47" fieldNum="47" val="90800205919001395601100000000008" lenHex="0032" valHex="3930383030323035393139303031333935363031313030303030303030303038"/>
<f name="Proprietary Field 48" fieldNum="48" val="819001z85601100000000008" lenHex="0024" valHex="3831393030317A3835363031313030303030303030303038"/>
<f name="Currency Code, Transaction" fieldNum="49" val="643" valHex="0643"/>
<f name="Currency Code, Cardholder Billing" fieldNum="51" val="643" valHex="0643"/>
<f name="Smart Card Specific Data (EMV)" fieldNum="55" val="910A12073E49A98826FD3030711C861A84DA0000158003770C060000271000000190A534793E8E0B5CF6" lenHex="0042"/>
<f name="Account Identification-1" fieldNum="102" val="FN_ACCOUNT_IDENT1" lenHex="17" valHex="464E5F4143434F554E545F4944454E5431"/>
<f name="Account Identification-2" fieldNum="103" val="FN_ACCOUNT_IDENT2" lenHex="17" valHex="464E5F4143434F554E545F4944454E5432"/>
<f name="Transaction Description" fieldNum="104" val="FN_TRANS_DESCRIPT" lenHex="17" valHex="464E5F5452414E535F4445534352495054"/>
<f name="Proprietary Field 112" fieldNum="112" lenHex="000085">
<f name="Local fleet data" tag="F0" tagHex="F0" lenHex="53">
<f name="Protocol Version" tag="C1" val="4204" tagHex="C1" lenHex="02"/>
<f name="Vehicle And Driver info" tag="E3" val="C11B54504F5254414C2020202020202020202020202020202020202020" tagHex="E3" lenHex="1D"/>
<f name="POS Additional Info" tag="E4" val="81024401820513102800058306131028100454" tagHex="E4" lenHex="13"/>
<f name="Commodity Info" tag="EA" tagHex="EA" lenHex="19">
<f name="Product" tag="FF01" tagHex="FF01" lenHex="16">
<f name="Commodity Code" tag="D1" val="T23" tagHex="D1" lenHex="03" valHex="543233"/>
<f name="Quantity" tag="D2" val="4204" tagHex="D2" lenHex="02"/>
<f name="Price" tag="D3" val="4202D5" tagHex="D3" lenHex="03"/>
<f name="Cost" tag="D5" val="4210" tagHex="D5" lenHex="02"/>
<f name="Additional Data" tag="D9" val="T1" tagHex="D9" lenHex="02" valHex="5431"/>
</f>
</f>
</f>
</f>
</f>
</f>
102字段具有BCD长度(一个字节)和ASCII正文
<f type="LEN_VAL" fieldNum="102" name="Account Identification-1" lengthPacker="BcdLengthPacker" bodyPacker="AsciiBodyPacker"/>
示例的源代码可以在GitHub上找到。
注意:我是iso-8583-packer library(Java)库的作者。