无法使用jpos和ISO 8583设置和解包字段127子元素033

时间:2019-03-22 15:05:27

标签: spring-boot iso8583 jpos

我正在挑战。我正在使用Jpos,并且试图设置字段127子元素033以及对其进行解压缩。打包时,看起来工作正常,但是尝试拆包时,出现以下异常。

  

由以下原因引起:org.jpos.iso.ISOException:org.jpos.iso.IFA_LLCHAR:问题   拆包字段11(java.lang.NegativeArraySizeException)拆包   字段= 127,已消耗= 287

如果我注释掉字段127.033的设置以及在fields.xml的字段127下删除id = 33的isofield,则一切正常。但是,当我取消上述评论时,错误再次浮出水面。

打包程序:

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.packager.GenericPackager;

import java.io.InputStream;
import java.text.SimpleDateFormat;

public class PackerTest {

        public static void main(String[] args) throws ISOException {
            InputStream is = com.melah.Pack.class.getResourceAsStream("/fields.xml");
            GenericPackager packager = new GenericPackager(is);


            ISOMsg isoMsg = new ISOMsg();
            isoMsg.setPackager(packager);


            isoMsg.set(0, "0200");
            isoMsg.set(2, "5000000000000000");
            isoMsg.set(3, "317000");
            isoMsg.set(4, "000000000000");
            isoMsg.set(7, new SimpleDateFormat("MMddHHmmss").format(1221133630));
            isoMsg.set(11, "594972");
            isoMsg.set(12, "153630");
            isoMsg.set(13, "1221");
            isoMsg.set(14, "1912");
            isoMsg.set(15, "1221");
            isoMsg.set(18, "6012");
            isoMsg.set(22, "020");
            isoMsg.set(25, "27");
            isoMsg.set(28, "C00000000");
            isoMsg.set(30, "C00000000");
            isoMsg.set(32, "588892");
            isoMsg.set(37, "000540000000");
            isoMsg.set(41, "11430000");
            isoMsg.set(42, "000000011431143");
            isoMsg.set(43, "XYZ Banking");
            isoMsg.set(49, "840");
            isoMsg.set(56, "1510");
            isoMsg.set(59, "0540000000");
            isoMsg.set(102, "5000000000000000");
            isoMsg.set(123, "100000000000000");
            isoMsg.set("127.003", "XYZ XYZ");
            isoMsg.set("127.033", "6000");
            isoMsg.set(54, "500000000");


            byte[] bIsoMsg = isoMsg.pack();

            String isoMessage = "";
            for (int i = 0; i < bIsoMsg.length; i++) {
                String a = "";
                isoMessage += (char) bIsoMsg[i];
            }
            System.out.println(" Packed ISO8385 Message = '"+isoMessage+"'");
        }

    }

解包器:

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
import org.jpos.iso.packager.GenericPackager;

import java.io.InputStream;

public class UnpackISOMessage {
    public static void main(String[] args) {
        UnpackISOMessage iso = new UnpackISOMessage();
        try {
            ISOMsg isoMsg = iso.parseISOMessage();
            iso.printISOMessage(isoMsg);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private ISOMsg parseISOMessage() throws Exception {
        String message = "0200F23E449508E0852000000000040000221650000000000000003170000000000000000115051213594972153630122119121221601202027C00000000C000000000658889200054000000011430000000000011431143XYZ Banking                             84000950000000000415100100540000000165000000000000000015100000000000000000060    タ   XYZ XYZ                                         6000";
        System.out.printf("Message = %s%n", message);
        try {
            InputStream is = getClass().getResourceAsStream("/fields.xml");
            GenericPackager packager = new GenericPackager(is);
            ISOMsg isoMsg = new ISOMsg();
            isoMsg.setPackager(packager);
            isoMsg.unpack(message.getBytes());
            return isoMsg;
        } catch (ISOException e) {
            throw new Exception(e);
        }
    }

    private void printISOMessage(ISOMsg isoMsg) {
        try {
            isoMsg.dump(System.out, "");
            System.out.println(ISOUtil.hexdump(isoMsg.pack()));

            System.out.printf("MTI = %s%n", isoMsg.getMTI());
            System.out.println("127.003 : " + isoMsg.getString("127.003"));
            System.out.println("127.033 : " + isoMsg.getString("127.033"));
            for (int i = 1; i <= isoMsg.getMaxField(); i++) {
                if (isoMsg.hasField(i)) {
                    System.out.printf("Field (%s) = %s%n", i, isoMsg.getString(i));
                }
            }
        } catch (ISOException e) {
            e.printStackTrace();
        }
    }
}

fields.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager SYSTEM "genericpackager.dtd">
<isopackager>
    <isofield id="0" length="4" name="MESSAGE TYPE INDICATOR" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="1" length="16" name="BIT MAP" class="org.jpos.iso.IFA_BITMAP"/>
    <isofield id="2" length="19" name="SECRET ID" class="org.jpos.iso.IFA_LLNUM"/>
    <isofield id="3" length="6" name="PROCESSING CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="4" length="12" name="AMOUNT, TRANSACTION" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="5" length="12" name="AMOUNT, SETTLEMENT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="6" length="12" name="AMOUNT, CARDHOLDER BILLING" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="7" length="10" name="TRANSMISSION DATE AND TIME" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="8" length="8" name="AMOUNT, CARDHOLDER BILLING FEE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="9" length="8" name="CONVERSION RATE, SETTLEMENT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="10" length="8" name="CONVERSION RATE, CARDHOLDER BILLING" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="11" length="6" name="SYSTEM TRACE AUDIT NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="12" length="6" name="TIME, LOCAL TRANSACTION" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="13" length="4" name="DATE, LOCAL TRANSACTION" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="14" length="4" name="DATE, EXPIRATION" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="15" length="4" name="DATE, SETTLEMENT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="16" length="4" name="DATE, CONVERSION" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="17" length="4" name="DATE, CAPTURE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="18" length="4" name="MERCHANTS TYPE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="19" length="3" name="ACQUIRING INSTITUTION COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="20" length="3" name="PAN EXTENDED COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="21" length="3" name="FORWARDING INSTITUTION COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="22" length="3" name="POINT OF SERVICE ENTRY MODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="23" length="3" name="CARD SEQUENCE NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="24" length="3" name="NETWORK INTERNATIONAL IDENTIFIEER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="25" length="2" name="POINT OF SERVICE CONDITION CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="26" length="2" name="POINT OF SERVICE PIN CAPTURE CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="27" length="1" name="AUTHORIZATION IDENTIFICATION RESP LEN" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="28" length="9" name="AMOUNT, TRANSACTION FEE" class="org.jpos.iso.IFA_AMOUNT"/>
    <isofield id="29" length="9" name="AMOUNT, SETTLEMENT FEE" class="org.jpos.iso.IFA_AMOUNT"/>
    <isofield id="30" length="9" name="AMOUNT, TRANSACTION PROCESSING FEE" class="org.jpos.iso.IFA_AMOUNT"/>
    <isofield id="31" length="9" name="AMOUNT, SETTLEMENT PROCESSING FEE" class="org.jpos.iso.IFA_AMOUNT"/>
    <isofield id="32" length="11" name="ACQUIRING INSTITUTION IDENT CODE" class="org.jpos.iso.IFA_LLNUM"/>
    <isofield id="33" length="11" name="FORWARDING INSTITUTION IDENT CODE" class="org.jpos.iso.IFA_LLNUM"/>
    <isofield id="34" length="28" name="PAN EXTENDED" class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield id="35" length="37" name="TRACK 2 DATA" class="org.jpos.iso.IFA_LLNUM"/>
    <isofield id="36" length="104" name="TRACK 3 DATA" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="37" length="12" name="RETRIEVAL REFERENCE NUMBER" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="38" length="6" name="AUTHORIZATION IDENTIFICATION RESPONSE" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="39" length="2" name="RESPONSE CODE" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="40" length="3" name="SERVICE RESTRICTION CODE" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="41" length="8" name="CARD ACCEPTOR TERMINAL IDENTIFICACION" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="42" length="15" name="CARD ACCEPTOR IDENTIFICATION CODE" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="43" length="40" name="CARD ACCEPTOR NAME/LOCATION" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="44" length="25" name="ADITIONAL RESPONSE DATA" class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield id="45" length="76" name="TRACK 1 DATA" class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield id="46" length="999" name="ADITIONAL DATA - ISO" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="47" length="999" name="ADITIONAL DATA - NATIONAL" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="48" length="999" name="ADITIONAL DATA - PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="49" length="3" name="CURRENCY CODE, TRANSACTION" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="50" length="3" name="CURRENCY CODE, SETTLEMENT" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="51" length="3" name="CURRENCY CODE, CARDHOLDER BILLING" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="52" length="16" name="PIN DATA" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="53" length="16" name="SECURITY RELATED CONTROL INFORMATION" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="54" length="120" name="ADDITIONAL AMOUNTS" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="55" length="999" name="RESERVED ISO" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="56" length="999" name="RESERVED ISO" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="57" length="999" name="RESERVED NATIONAL" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="58" length="999" name="RESERVED NATIONAL" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="59" length="999" name="RESERVED NATIONAL" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="60" length="999" name="RESERVED PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="61" length="999" name="RESERVED PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="62" length="999" name="RESERVED PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="63" length="999" name="RESERVED PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="64" length="8" name="MESSAGE AUTHENTICATION CODE FIELD" class="org.jpos.iso.IFA_BINARY"/>
    <isofield id="65" length="1" name="BITMAP, EXTENDED" class="org.jpos.iso.IFA_BINARY"/>
    <isofield id="66" length="1" name="SETTLEMENT CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="67" length="2" name="EXTENDED PAYMENT CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="68" length="3" name="RECEIVING INSTITUTION COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="69" length="3" name="SETTLEMENT INSTITUTION COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="70" length="3" name="NETWORK MANAGEMENT INFORMATION CODE" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="71" length="4" name="MESSAGE NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="72" length="4" name="MESSAGE NUMBER LAST" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="73" length="6" name="DATE ACTION" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="74" length="10" name="CREDITS NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="75" length="10" name="CREDITS REVERSAL NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="76" length="10" name="DEBITS NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="77" length="10" name="DEBITS REVERSAL NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="78" length="10" name="TRANSFER NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="79" length="10" name="TRANSFER REVERSAL NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="80" length="10" name="INQUIRIES NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="81" length="10" name="AUTHORIZATION NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="82" length="12" name="CREDITS, PROCESSING FEE AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="83" length="12" name="CREDITS, TRANSACTION FEE AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="84" length="12" name="DEBITS, PROCESSING FEE AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="85" length="12" name="DEBITS, TRANSACTION FEE AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="86" length="16" name="CREDITS, AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="87" length="16" name="CREDITS, REVERSAL AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="88" length="16" name="DEBITS, AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="89" length="16" name="DEBITS, REVERSAL AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="90" length="42" name="ORIGINAL DATA ELEMENTS" class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield id="91" length="1" name="FILE UPDATE CODE" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="92" length="2" name="FILE SECURITY CODE" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="93" length="6" name="RESPONSE INDICATOR" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="94" length="7" name="SERVICE INDICATOR" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="95" length="42" name="REPLACEMENT AMOUNTS" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="96" length="16" name="MESSAGE SECURITY CODE" class="org.jpos.iso.IFA_BINARY"/>
    <isofield id="97" length="17" name="AMOUNT, NET SETTLEMENT" class="org.jpos.iso.IFA_AMOUNT"/>
    <isofield id="98" length="25" name="PAYEE" class="org.jpos.iso.IF_CHAR"/>
    <isofield id="99" length="11" name="SETTLEMENT INSTITUTION IDENT CODE" class="org.jpos.iso.IFA_LLNUM"/>
    <isofield id="100" length="11" name="RECEIVING INSTITUTION IDENT CODE" class="org.jpos.iso.IFA_LLNUM"/>
    <isofield id="101" length="17" name="FILE NAME" class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield id="102" length="28" name="FROM ACCOUNT" class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield id="103" length="10" name="ACCOUNT IDENTIFICATION 2" class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield id="104" length="100" name="TRANSACTION DESCRIPTION" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="105" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="106" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="107" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="108" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="109" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="110" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="111" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="112" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="113" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="114" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="115" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="116" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="117" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="118" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="119" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="120" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="121" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="122" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="123" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="124" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="125" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield id="126" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
    <!--<isofield id="127" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>-->
    <isofieldpackager
            id="127"
            length="999999"
            name="RESERVED PRIVATE USE"
            class="org.jpos.iso.IFA_LLLLLLBINARY"
            packager="org.jpos.iso.packager.GenericSubFieldPackager">
        <isofield
                id="0"
                length="0"
                name="PLACEHOLDER"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="1"
                length="8"
                name="BITMAP"
                class="org.jpos.iso.IFB_BITMAP"/>
        <isofield
                id="2"
                length="32"
                name="SWITCH KEY"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="3"
                length="48"
                name="ROUTING INFORMATION"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="4"
                length="22"
                name="POS DATA"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="5"
                length="73"
                name="SERVICE STATION DATA"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="6"
                length="2"
                name="AUTHORIZATION PROFILE"
                class="org.jpos.iso.IFA_NUMERIC"/>
        <isofield
                id="7"
                length="50"
                name="CHECK DATA"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="8"
                length="128"
                name="RETENTION DATA"
                class="org.jpos.iso.IFA_LLLCHAR"/>
        <isofield
                id="9"
                length="255"
                name="ADDITIONAL NODE DATA"
                class="org.jpos.iso.IFA_LLLCHAR"/>
        <isofield
                id="10"
                length="3"
                name="CVV2"
                class="org.jpos.iso.IFA_NUMERIC"/>
        <isofield
                id="11"
                length="32"
                name="ORIGINAL KEY"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="12"
                length="25"
                name="TERMINAL OWNDER"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="13"
                length="17"
                name="POS GEOGRAPHIC DATA"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="14"
                length="8"
                name="SPONSOR BANK"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="15"
                length="29"
                name="AVS REQUEST"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="16"
                length="1"
                name="AVS RESPONSE"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="17"
                length="50"
                name="CARDHOLDER INFORMATION"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="18"
                length="50"
                name="VALIDATION DATA"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="19"
                length="45"
                name="BANK DETAILS"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="20"
                length="8"
                name="AUTHORIZER DATE SETTLEMENT"
                class="org.jpos.iso.IFA_NUMERIC"/>
        <isofield
                id="21"
                length="12"
                name="RECORD IDENTIFICATION"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="22"
                length="99999"
                name="MSDN"
                class="org.jpos.iso.IFA_LLLLLCHAR"/>
        <isofield
                id="23"
                length="253"
                name="PAYEE NAME AND ADDRESS"
                class="org.jpos.iso.IF_CHAR"/>
        <isofield
                id="24"
                length="28"
                name="PAYER ACCOUNT INFORMATION"
                class="org.jpos.iso.IFA_LLCHAR"/>
        <isofield
                id="25"
                length="8000"
                name="ICC DATA"
                class="org.jpos.iso.IFA_LLLLCHAR"/>
        <isofield
                id="33"
                length="4"
                name="EXTENDED TRAN-TYPE"
                class="org.jpos.iso.IFA_NUMERIC"/>
    </isofieldpackager>
    <isofield id="128" length="8" name="MAC 2" class="org.jpos.iso.IFA_BINARY"/>
</isopackager>

例外:

Message = 0200F23E449508E0852000000000040000221650000000000000003170000000000000000115051213594972153630122119121221601202027C00000000C000000000658889200054000000011430000000000011431143XYZ Banking                             84000950000000000415100100540000000165000000000000000015100000000000000000060    タ   XYZ XYZ                                         6000
java.lang.Exception: org.jpos.iso.ISOException: org.jpos.iso.IFA_LLCHAR: Problem unpacking field 11 (java.lang.NegativeArraySizeException) unpacking field=127, consumed=287
    at com.melah.UnpackISOMessage.parseISOMessage(UnpackISOMessage.java:32)
    at com.melah.UnpackISOMessage.main(UnpackISOMessage.java:14)
Caused by: org.jpos.iso.ISOException: org.jpos.iso.IFA_LLCHAR: Problem unpacking field 11 (java.lang.NegativeArraySizeException) unpacking field=127, consumed=287
    at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:340)
    at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:468)
    at com.melah.UnpackISOMessage.parseISOMessage(UnpackISOMessage.java:29)
    ... 1 more

Jpos Maven依赖性:

<dependency>
            <groupId>org.jpos</groupId>
            <artifactId>jpos</artifactId>
            <version>2.1.2</version>
</dependency>

代码可以在github上找到: https://github.com/melah500/jpos-field-127.003

1 个答案:

答案 0 :(得分:0)

感谢您的所有答复,可以帮助我解决此问题。我设法弄清楚问题出在哪里。最初,导致数据无法解包的原因是与字段127.11有关。好吧,在我的情况下,我真的没有用到该字段,因此我只是将其从包装程序中删除了。然后,为了解决第二个问题,即字段127.33中的数据被截断,我使用了我在PackerTest中生成的字符串isoMessage,因此该字符串包含一些二进制数据,因此在此过程中丢失了一些数据。我只需要使用字节格式的消息来避免任何意外。或者,我可以使用IsoUtil使用来自hexdump的hex值。我刚刚在github上更新了代码,可能有人觉得它有用。

代码可在github上找到:https://github.com/melah500/jpos-field-127.003

谢谢。