代码之家  ›  专栏  ›  技术社区  ›  Alvin

ISO 8583 ALPHA未转换为十六进制

  •  1
  • Alvin  · 技术社区  · 6 年前

    配置:

    <template type="0500">
            <field num="3" type="NUMERIC" length="6">920000</field>
            <field num="11" type="NUMERIC" length="6" />
            <field num="24" type="NUMERIC" length="3" />
            <field num="41" type="ALPHA" length="8" />
            <field num="42" type="ALPHA" length="15" />
    </template>
    

    代码:

    MessageFactory mfact = ConfigParser
                        .createFromClasspathConfig("config.xml");
                mfact.setTraceNumberGenerator(new SimpleTraceGenerator((int) (System.currentTimeMillis() % 100000)));
    
                m = mfact.newMessage(0x500);
                m.setValue(24, 109, IsoType.NUMERIC, 3);
                m.setValue(41, "10986312", IsoType.ALPHA, 8);
                m.setValue(42, "000001106020132", IsoType.ALPHA, 15);
    
                String strMsg = new String(msg.writeData());
    

    strMsg 给了我这个结果:

    05 00 20 20 01 00 00 C0 00 00 92 00 00 04 42 18 10 91 09 86 31 20 00 00 11 06 02 01 32
    

    但结果应该是:

    05 00 20 20 01 00 00 C0 00 00  92 00 00 04 42 18 01 09 31 30 39 38 36 33 31 32 30 30 30 30 30 31 31 30 36 30 32 30 31 33 32
    

    哪里:

    field 24 => 109 should be 0109
    field 41 => 10986312 should be in hex 3130393836333132
    feild 42 => 000001106020132 should be in hex 303030303031313036303230313332
    

    字段41和42都是字母数字特殊字符字段。

    我应该用吗 HexCodec.hexEncode 在使用TCP/IP发送到主机之前,整个消息还是部分消息?

    0 回复  |  直到 6 年前