Search code examples
javaisounpackhexdumpjpos

ISO8583 Unpack Issue


How I will unpack ISO message using JPOS library in java?

here is the sample ISO message.

0800. ..............1224190516424997001003      
Sample Hex Dump:
30 38 30 30 82 20 01 00  00 00 00 00 04 00 00 00      0800. ..........
00 00 00 00 31 32 32 34  31 39 30 35 31 36 34 32      ....122419051642
34 39 39 37 30 30 31 30  30 33                        4997001003    

Please note that I have packed this above message using jpos library and bit map format is org.jpos.iso.IFB_BITMAP


Solution

  • If you want to unpack from the data you shared, you just need to use the same packager you used to pack the iso message to unpack what you generated.

    You can instantiate a packager with the same parameters you used to pack the message and then:

    ISOPackager pacakger = ....; //initialize the same way as used to pack
    ISOMsg m = new ISOMsg();
    //here we are using the hexdump since the plain data has non printable chars, because of the binary bitmap
    byte[] packed = ISOUtil.decodeHexDump(
                    "30 38 30 30 82 20 01 00  00 00 00 00 04 00 00 00      0800. ..........\n" +
                    "00 00 00 00 31 32 32 34  31 39 30 35 31 36 34 32      ....122419051642\n" +
                    "34 39 39 37 30 30 31 30  30 33                        4997001003");
    packager.unpack(m, packed);
    

    Alternatively you can

    ISOMsg m = new ISOMsg();
    m.setPackager(packager);
    m.unpack(packed);
    

    Provided that packed and packager variables are initialized in the ssame way as above.

    And you will have the iso message content in the m variable.