本文介绍了使用jpos api打包SUBFIELDS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个使用 jpos框架打包和解压缩 ISOMessage 的主文件.

I'm trying to write a main that packs and unpacks an ISOMessage using jpos framework.

问题是我的邮件中包含某些子字段,例如字段48 ,而我一直将其作为空值获取.

The problem is that my message contains some sub_fields like field 48, and i keep getting it as null value.

低于我的配置+主程序

包装器

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE isopackager PUBLIC
        "-//jPOS/jPOS Generic Packager DTD 1.0//EN"
        "http://jpos.org/dtd/generic-packager-1.0.dtd">
<!-- ISO 8583:1993 (ASCII) field descriptions for GenericPackager -->

<isopackager>

    <isofield id="0" length="4" name="Message Type Indicator"
        class="org.jpos.iso.IFA_NUMERIC" />

    <isofield id="1" length="64" name="Bitmap" class="org.jpos.iso.IFA_BITMAP" />

    <isofield id="2" length="19" name="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="7" length="10" name="DATE AND TIME, TRANSMISSION"
        class="org.jpos.iso.IFA_NUMERIC" />

    <isofield id="11" length="6" name="Systems 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="18" length="4" name="Merchant type" class="org.jpos.iso.IFA_NUMERIC" />

    <isofield id="22" length="4" name="Point of service entry mode code"
        class="org.jpos.iso.IFA_NUMERIC" />

    <isofield id="25" length="2" name="POS Condition code" class="org.jpos.iso.IFA_NUMERIC" ></isofield>

    <isofield id="41" length="8"
        name="Card acceptor terminal identification" class="org.jpos.iso.IF_CHAR" ></isofield>

    <isofield id="42" length="15" name="Card acceptor identification code"
        class="org.jpos.iso.IF_CHAR" />

    <isofieldpackager id="48"
        length="255"
        name="Additional private data"
        class="org.jpos.iso.IFA_LLLNUM"
        emitBitmap="false"
        packager="org.jpos.iso.packager.GenericSubFieldPackager">
      <isofield   
          id="1"
          length="8"
          name="PSP Identifier"
          class="org.jpos.iso.IFA_NUMERIC"/>
      <isofield
          id="2"
          length="8"
          name="Ecommerce Acquirer Identifier"
          class="org.jpos.iso.IFA_NUMERIC"/>
    </isofieldpackager>

    <isofield id="49" length="3" name="Currency Code, Transaction"
        class="org.jpos.iso.IFA_NUMERIC" />

</isopackager>

main.java

      public static void main(String[] args) throws ISOException {
                IServicesUtils service = new ServiceUtilsImpl();
                String filePackager = (String) service
                        .getValuesFromPropertiesFile(new String[] { IConstants.DEMO_PACKAGER_LOCATION },
                                "parameters.properties")
                        .get(IConstants.DEMO_PACKAGER_LOCATION);
                GenericPackager packager = new GenericPackager(filePackager);

                ISOMsg isoMsg = new ISOMsg();
                isoMsg.setPackager(packager);
                isoMsg.setMTI("1100");
                isoMsg.set("2", "1111110000000010");
                isoMsg.set("3", "000000");
                isoMsg.set("4", StringUtils.leftPad("116.0", 12, "0"));
                isoMsg.set("7", DateUtils.getTransmissionDate(new Date()));
                isoMsg.set("11", service.generateSTAN());
                isoMsg.set("12", DateUtils.getField12Iso("1207"));
                isoMsg.set("13", DateUtils.getField13Iso("1105"));
                isoMsg.set("14", "0808");
                isoMsg.set("18", "3306");
                isoMsg.set("22", "....");
                isoMsg.set("25", "59");
                isoMsg.set("41", "59002300");
                isoMsg.set("42", "111110000012345");
                isoMsg.set("48", "111110000077658");
                isoMsg.set("48.1", "00221166");
                isoMsg.set("49", "804");

                logISOMsg(isoMsg);

                byte[] data = isoMsg.pack();

                logger.info("RESULT : " + new String(data));
            }


      private static void logISOMsg(ISOMsg msg) {
            System.out.println("----ISO MESSAGE-----");
            try {
                System.out.println("  MTI : " + msg.getMTI());
                for (int i = 1; i <= msg.getMaxField(); i++) {
                    if (msg.hasField(i)) {
                        logger.info("    Field-" + i + " : " + msg.getString(i));
                    }
                }
            } catch (ISOException e) {
                e.printStackTrace();
            } finally {
                System.out.println("--------------------");
            }
        }

此主菜单打印除字段48外的所有字段,并返回 null 值.不知道为什么,在包装方面还是有其他问题?

This main prints all the field except field 48, it returns null value. don't know why, is there a problem at packaging level, or something else.

推荐答案

字段48的外部包装程序必须为二进制类,即IFA_LLLBINARY或IFB_LLLBINARY,具体取决于您的规范.如果没有字段0,则可能必须添加firstField属性并将其设置为1.或者,可以将字段0定义为IF_NOP(无操作).

Your outer packager for field 48 has to be of binary class, i.e. IFA_LLLBINARY or IFB_LLLBINARY depending on your spec. You may have to add the firstField attribute and set it to 1 if there's no field 0. As an alternative, you can define field 0 as IF_NOP (no operation).

这篇关于使用jpos api打包SUBFIELDS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 17:52