为什么ISO8583解包会产生无效值?

33qvvth1  于 2021-07-06  发布在  Java
关注(0)|答案(4)|浏览(540)

我需要解包并得到mti,表示数据元素的值

303831308220000002000000040000000000000031313233303930323333303733313536303033303

1个消息字符串。如您所见,mti应该是 3038 但是当我用 isoMsg.getMTI(); 它给出的声明 0810 作为输出。那么我的代码有什么问题?请参阅本教程。https://kodejava.org/how-do-i-unpack-an-iso-8583-message/ 在那里前四个领域来作为mti,但我没有得到我的前四个领域作为mti。请提供一个详细的答案。

public class IsoUnpacker {

    public static void main(String[] args) {
        String message = "3038313082200000020000000400000000000000313132333039303233333037333135363030333031";

        IsoUnpacker iso = new IsoUnpacker();
        try {
            ISOMsg isoMsg = iso.parseISOMessage(message);
            iso.printISOMessage(isoMsg);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private ISOMsg parseISOMessage(String message) throws Exception {

        System.out.printf("Message = %s%n", message);
        try {

            ISOMsg isoMsg= new ISOMsg();

            GenericValidatingPackager packager  = new GenericValidatingPackager();
            packager.readFile("C:\\Users\\Hasindu\\Documents\\ISO_Unpacker\\iso_unpacking\\src\\resources\\fields.xml");

            isoMsg.setPackager(packager);
            isoMsg.unpack(ISOUtil.hex2byte(message));

            return isoMsg;
        } catch (ISOException e) {
            System.out.println(e.getMessage());
        }
        return null ;
    }

    private void printISOMessage(ISOMsg isoMsg) {
        try {
            System.out.printf("MTI = %s%n", isoMsg.getMTI());
            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 PUBLIC
        "-//jPOS/jPOS Generic Packager DTD 1.0//EN"
        "http://jpos.org/dtd/generic-packager-1.0.dtd">

<!-- ISO 8583:1987 (ASCII) field descriptions for GenericPackager -->
<!-- Bitmap is BINARY in this case -->

<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.IFB_BITMAP"/>
    <isofield
            id="2"
            length="19"
            name="PAN - PRIMARY ACCOUNT NUMBER"
            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="8"
            name="PIN DATA"
            class="org.jpos.iso.IFA_BINARY"/>
    <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="ACCOUNT IDENTIFICATION 1"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield
            id="103"
            length="28"
            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"/>
    <isofield
            id="128"
            length="8"
            name="MAC 2"
            class="org.jpos.iso.IFA_BINARY"/>
</isopackager>

输出:

Message = 3038313082200000020000000400000000000000313132333039303233333037333135363030333031
MTI = 0810
Field (7) = 1123090233
Field (11) = 073156
Field (39) = 00
Field (70) = 301
l0oc07j2

l0oc07j21#

在你的方法中一切都是好的,每个人都试着解释相同的,但是请允许我先为你澄清基本知识,然后将尝试回答你在op或评论中提出的所有问题。
理解ISO8583(免责声明:我的话&来自维基百科)
它是金融交易消息传递的国际标准。它有一个明确的格式和许多大计划,如万事达卡,签证利用它。根据定义,前4位是mti->消息类型指示符。以此类推,带位置的数字有明确的含义。
基本上定义了这是什么样的信息?现在,如前所述,这是一个标准协议,意味着即使是有效的mti也被定义。所以,在学习或理解ISO8583的同时,你应该开始学习什么是有效的MTI?
现在我强烈建议在进一步阅读之前先阅读这一部分:mti\u wiki
阅读之后,您可能已经理解了-消息类型指示符包括iso8583版本、消息类、消息函数和消息源。也就是说:这4个数字解释了以上3件事。
以您的信息为例: 303831x 现在,如果我们看一下你的信息,再看一下我在上面分享的链接,第一个数字是3 3038xx 根据iso 8583,不可使用,而是由iso自己保留。

这意味着-你最初期望的mti是什么 3038 -甚至不是有效的mti!!这更应该让你意识到,这要么是一个错误的信息,要么是通过某种方式编码的信息。
在您的案例中,它是后者,因为它是十六进制编码的消息,这是完全正确的,因为许多业务实体可以选择任何类型的协议。
话虽如此,您必须理解为了使用任何iso库来打包或解包或任何其他东西,您必须首先将您的信息翻译为有效的iso 8583格式。
所以你决定 isoMsg.unpack(ISOUtil.hex2byte(message)); 在这种情况下是绝对有效的,当然 isoMsg.unpack(message.getBytes()); 一定会失败因为当你说 message.getBytes() 您没有将有效的iso 8583消息传递给标准解包函数。
所以在你的留言里: Message = 3038313082200000020000000400000000000000313132333039303233333037333135363030333031 具有30383130(十六进制编码)是 MTI = 0810
如何知道消息是否为base-16(十六进制编码)?
为此,强烈建议与发起方收单机构/终端/anyinterface达成协议,让消费者/银行/anyinterface知道消息将以何种格式到达。
这些是整个组织的标准实践,这样就可以配置响应者。我敢肯定,从这个发起者那里,你收到的是303831,明天你不会开始收到0810xx(就像ascii一样),除非他们改变了终端的配置/设置,必须通知你/你的公司。至于金融交易的成功,所有具有约束力的当事方都可以发挥作用。
我无法回忆起任何库来检测编码,当然,你可以有一些东西,可以检测,但我仍然要求得到这一标准化,作为双方之间的协议,就像我上面说的。
专业提示:随着时间的推移,你将能够告诉自己的编码或什么样的消息,只要看mti;)!相信我!
希望我回答了你所有的疑问,如果再问也不要犹豫。祝你好运!

col17t5w

col17t5w2#

这是一个有效且格式良好的消息。mti 0810=网络管理响应,字段70,网络管理信息代码,301表示回声测试,字段39=00表示正常,字段11是系统跟踪审核编号,是将响应与请求联系起来的消息的id,字段7是日期和时间,11月23日09:02:33。
位图为8220000000000。数一数,从1开始,得到1,7,11,39和70。字段1是第二个位图。
ISO8583是一个相当松散的标准,每个实现都略有不同。例如,每个卡片品牌都有自己的版本。但这个特殊的例子是标准的。
我没有将其与您提供的参考进行比较,而是与标准的一个版本进行比较。

ffscu2ro

ffscu2ro3#

这不是一个完整的答案,但它太大了,无法发表评论,可能会帮助你找出问题所在。
注:

3038313082200000020000000400000000000000313132333039303233333037333135363030333031

这似乎是一个十六进制编码的ascii字符串,在开头附近有一些二进制内容
如果我转换成ascii,而猜测二进制位是32位的小endian整数,我得到

"0810" ASCII
0x00002082 
0x00000002
0x00000004
0x00000000
"112309023307315600301" ASCII

我希望这能帮助你解决问题。

xkftehaa

xkftehaa4#

试试这个:

package org.kodejava.example.jpos;

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

import java.io.InputStream;

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

    private ISOMsg parseISOMessage(String message) throws Exception {
        System.out.printf("Message = %s%n", message);
        try {
            // Load package from resources directory.
            InputStream is = getClass().getResourceAsStream("C:\\Users\\Hasindu\\Documents\\ISO_Unpacker\\iso_unpacking\\src\\resources\\fields.xm");
            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 {
            System.out.printf("MTI = %s%n", isoMsg.getMTI());
            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();
        }
    }
}

相关问题