JPOS ISO8583 unpack field 63 problems

679 views
Skip to first unread message

shivjanam sonkar

unread,
Sep 5, 2018, 12:46:23 PM9/5/18
to jPOS Users
Hi JPOS team,
i am new on JPOS and i was trying to parse the iso message, but i was unable to fully parse the field 63.

i am getting the below response using wireshark:
006860000000001987000101081020380000028000029800000000961221380905303031303030303130370061005937316493f2a48e365938b5dbc8a667235f3e366d0605b7f54a3c1f03e205707b331f757d4a967a76d9842c3f9a284b65526e303c174496d92e30ed

Data field 63: 
0061005937316493f2a48e365938b5dbc8a667235f3e366d0605b7f54a3c1f03e205707b331f757d4a967a76d9842c3f9a284b65526e303c174496d92e30ed
where 0061 is the length
and 0059 ==> data length (BCD)
3731   ==> data ID(71, ASCII NUMERIC)
6493f2a48e365938b5dbc8a667235f3e366d0605b7f54a3c1f03e205707b331f757d4a967a76d9842c3f9a284b65526e303c174496d92e30ed ==> Data 

but i am getting only below data when i am using the attched iso87binary.xml
005937316493F2A48E365938B5=BC8A667235F3E366=0605B7F54A3C1F03E

my question is :
  1. getting the half length of the data
  2. getting wrong data as we got new character = in the data.
ISO field 63 format is :
  <isofield
      id="63"
      length="999"
      name="RESERVED PRIVATE"
      class="org.jpos.iso.IFB_LLLNUM"/>

below is the Channel configuration:

<channel-adaptor name='jpos-channel' class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.NACChannel" packager="org.jpos.iso.packager.GenericPackager" header="60000000001987000101">
<property name="packager-config" value="cfg/packager/iso87binarypaycraft.xml" />
<property name="host" value="XXX.XXX.XXX.XXX" />
<property name="port" value="XXXX" />
<property name="connection-timeout" value="15000" />
<property name="timeout" value="300000"/>
<property name="keep-alive" value="true" />
</channel>
<in>jpos-send</in>
<out>jpos-receive</out>
</channel-adaptor>


Please help me to resolve this above problem.

iso87binary.xml

chhil

unread,
Sep 5, 2018, 10:58:45 PM9/5/18
to jpos-...@googlegroups.com

Hi, 
Its difficult to understand what your wireshark data includes. I would suggest extracting the tcp payload and providing that hexdump.

e.g. I have a 0100 ISO8583 message , select the TCP payload, right click and copy the hex + ascii.
Provide that copied info.

image.png

e.g. of the copied bytes. 
This format is a lot more helpful as I can see what data was travelling on the wire. Then we can start looking into your problem.

0000   01 1e 30 31 30 30 f2 3c 65 01 88 e1 80 0c 00 00   ..0100ò<e..á....
0010   00 00 00 00 00 02 31 35 37 30 31 31 34 30 30 30   ......1570114000
0020   30 30 30 31 31 31 31 30 30 30 30 30 30 30 30 30   0001111000000000
0030   30 30 30 30 30 30 30 37 30 30 36 32 36 31 35 30   0000000700626150
0040   33 30 30 30 30 30 30 30 31 31 31 30 32 35 39 30   3000000011102590
0050   36 32 36 31 31 31 31 35 34 31 31 38 34 30 30 32   6261111541184002
0060   32 31 30 30 30 36 30 30 30 30 30 30 30 36 30 30   2100060000000600
0070   30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 31   0000000000000001
0080   32 39 34 31 30 30 35 31 36 30 31 31 30 31 36 35   2941005160110165
0090   32 30 30 30 39 39 31 57 61 6c 2d 4d 61 72 74 20   2000991Wal-Mart 
00a0   53 75 70 65 72 20 43 65 6e 74 65 72 20 20 41 4c   Super Center  AL
00b0   50 48 41 52 45 54 54 41 20 20 20 20 47 41 20 30   PHARETTA    GA 0
00c0   32 35 57 41 4c 31 20 20 20 20 20 20 35 37 33 31   25WAL1      5731
00d0   35 32 36 30 35 38 30 37 36 31 34 38 34 30 30 31   5260580761484001
00e0   33 30 31 30 30 30 30 30 30 30 30 37 30 30 30 33   3010000000070003
00f0   39 37 30 32 20 53 57 20 38 74 68 20 53 74 72 65   9702 SW 8th Stre
0100   65 74 20 20 20 20 20 33 30 30 30 34 30 30 30 30   et     300040000
0110   30 30 30 30 32 39 34 31 30 30 35 30 33 31 33 31   0000294100503131

-chhil


--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/0e194d06-a936-4598-ad4e-ad973eec953d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chhil

unread,
Sep 6, 2018, 12:28:27 AM9/6/18
to jpos-...@googlegroups.com
Hi,
Don't bother with a better wireshark trace data.
Changed field 63 packager to 
<isofield
id="63"
length="999"
name="RESERVED PRIVATE"
class="org.jpos.iso.IFB_LLLBINARY"/>

package sample;

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
import org.jpos.iso.packager.GenericPackager;
import org.jpos.util.Logger;
import org.jpos.util.SimpleLogListener;

public class UnpackISOMessagePostPack {

    public static void main(String[] args) {

        // Spotted a 0810 response and excluded the other tcp low level headers
        // from the data you provided.
        String message = "081020380000028000029800000000961221380905303031303030303130370061005937316493f2a48e365938b5dbc8a667235f3e366d0605b7f54a3c1f03e205707b331f757d4a967a76d9842c3f9a284b65526e303c174496d92e30ed";

        Logger l = new Logger();
        l.addListener(new SimpleLogListener());
        ISOMsg m = new ISOMsg();
        GenericPackager p;
        try {
            p = new GenericPackager("C:\\temp\\iso87binary.xml");
            m.setPackager(p);
            p.setLogger(l, "blah");
            System.out.println(ISOUtil.hexdump(ISOUtil.str2bcd(message, true)));
            m.unpack(ISOUtil.str2bcd(message, true)); // Need to do this based
                                                      // on the wireshark data
                                                      // you have provided.
            m.dump(System.out, "");
            System.out.println(ISOUtil.hexdump(m.pack()));

        }
        catch (ISOException e) {

            e.printStackTrace();
            m.dump(System.out, "");
        }

    }

}
output
All the data seems to be consumed and the pack on the unpacked message provides the same hexdump as the input message.
0000  08 10 20 38 00 00 02 80  00 02 98 00 00 00 00 96  .. 8............
0010  12 21 38 09 05 30 30 31  30 30 30 30 31 30 37 00  .!8..0010000107.
0020  61 00 59 37 31 64 93 62  14 B5 36 59 38 25 72 38  a.Y71d.b..6Y8%r8
0030  16 67 23 76 35 36 74 06  05 27 65 71 33 36 03 52  .g#v56t..'eq36.R
0040  05 70 72 33 36 75 74 71  96 71 76 49 84 33 36 B1  .pr36utq.qvI.36.
0050  28 72 65 52 75 30 33 17  44 96 49 35 30 74        (reRu03.D.I50t

<log realm="blah" at="2018-09-06T09:52:58.304" lifespan="1ms">
  <unpack>
    0810203800000280000298000000009612213809053030313030303031303700610059373164936214B536593825723816672376353674060527657133360352057072333675747196717649843336B12872655275303317449649353074
    <bitmap>{3, 11, 12, 13, 39, 41, 63}</bitmap>
    <unpack fld="3" packager="org.jpos.iso.IFB_NUMERIC">
      <value>980000</value>
    </unpack>
    <unpack fld="11" packager="org.jpos.iso.IFB_NUMERIC">
      <value>000096</value>
    </unpack>
    <unpack fld="12" packager="org.jpos.iso.IFB_NUMERIC">
      <value>122138</value>
    </unpack>
    <unpack fld="13" packager="org.jpos.iso.IFB_NUMERIC">
      <value>0905</value>
    </unpack>
    <unpack fld="39" packager="org.jpos.iso.IF_CHAR">
      <value>00</value>
    </unpack>
    <unpack fld="41" packager="org.jpos.iso.IF_CHAR">
      <value>10000107</value>
    </unpack>
    <unpack fld="63" packager="org.jpos.iso.IFB_LLLBINARY">
      <value type='binary'>0059373164936214B536593825723816672376353674060527657133360352057072333675747196717649843336B12872655275303317449649353074</value>
    </unpack>
  </unpack>
</log>
<isomsg>
  <!-- org.jpos.iso.packager.GenericPackager[C:\SourceRepo\OII\Incomm\build\cfg\iso87binary.xml] -->
  <field id="0" value="0810"/>
  <field id="3" value="980000"/>
  <field id="11" value="000096"/>
  <field id="12" value="122138"/>
  <field id="13" value="0905"/>
  <field id="39" value="00"/>
  <field id="41" value="10000107"/>
  <field id="63" value="0059373164936214B536593825723816672376353674060527657133360352057072333675747196717649843336B12872655275303317449649353074" type="binary"/>
</isomsg>
<log realm="blah" at="2018-09-06T09:52:58.402" lifespan="1ms">
  <pack>
    0810203800000280000298000000009612213809053030313030303031303700610059373164936214B536593825723816672376353674060527657133360352057072333675747196717649843336B12872655275303317449649353074
  </pack>
</log>
0000  08 10 20 38 00 00 02 80  00 02 98 00 00 00 00 96  .. 8............
0010  12 21 38 09 05 30 30 31  30 30 30 30 31 30 37 00  .!8..0010000107.
0020  61 00 59 37 31 64 93 62  14 B5 36 59 38 25 72 38  a.Y71d.b..6Y8%r8
0030  16 67 23 76 35 36 74 06  05 27 65 71 33 36 03 52  .g#v56t..'eq36.R
0040  05 70 72 33 36 75 74 71  96 71 76 49 84 33 36 B1  .pr36utq.qvI.36.
0050  28 72 65 52 75 30 33 17  44 96 49 35 30 74        (reRu03.D.I50t

-chhil

shivjanam sonkar

unread,
Sep 6, 2018, 12:40:47 AM9/6/18
to jPOS Users
Hi,
please find the attached Req_response_wiresharkData.txt 

After parsing i got only these below data 
005937311E39B1A90A8E7FF6E73=46581EBBE8E4FF1=B252591940318953=

which is not correct, i need all the data inside the field 63, without change.
inside the field 63 there is a subfield 71.
Subfield 71 format is LTV(length Tag Value)
length in the BCD format 
TAG is 71 format ASCII NUMERIC 
in wireshark data is field 63 is : 0061005937311e39b1a90a8e7ff6e73d46581ebbe8e4ff1db252591940318953d2bfe58b4f43808f05acfd3b0183a07d08ca9bcca8e5ad85537c4ee254c563
where 
0061 ==> DE 63 length
0059 ==> Data Length(including Table id length) 
3731 ==> Table id (71)
1e39b1a90a8e7ff6e73d46581ebbe8e4ff1db252591940318953d2bfe58b4f43808f05acfd3b0183a07d08ca9bcca8e5ad85537c4ee254c563 ==> Data

I want this data "1e39b1a90a8e7ff6e73d46581ebbe8e4ff1db252591940318953d2bfe58b4f43808f05acfd3b0183a07d08ca9bcca8e5ad85537c4ee254c563" to our application

Please help me to get this data.

Thanks 
Req_response_wiresharkData.txt

shivjanam sonkar

unread,
Sep 6, 2018, 1:01:17 AM9/6/18
to jPOS Users
Hi Chill,
Thank you, as suggested by you, i have changed the iso87binary.xml file 
<isofield
id="63"
length="999"
name="RESERVED PRIVATE"
class="org.jpos.iso.IFB_LLLBINARY"/>

but request seems incorrect as field 63 is going into ASCII, how to change the request field 63 ?
Please see the attached file Incorrect_req_res.txt 
Incorrect_req_res.txt

chhil

unread,
Sep 6, 2018, 2:25:37 AM9/6/18
to jpos-...@googlegroups.com
The data you are setting needs to be massaged a bit since the field is binary and it will send the data as is without trying to reinterpret it.
ISOUtil.str2bcd is what you need to use on your data while setting it.

0000   00 99 60 00 00 00 00 19 87 00 01 01 08 00 20 20   ..`...........  
0010   00 00 00 e0 00 02 98 00 00 00 00 96 31 30 30 30   ...à........1000
0020   30 31 30 37 31 30 30 30 30 30 30 31 30 30 30 30   0107100000010000
0030   30 30 31 20 20 20 53 55 52 41 54 20 53 49 54 49   001   SURAT SITI
0040   4c 49 4e 4b 20 4c 74 64 2e 20 20 20 20 20 20 20   LINK Ltd.       
0050   20 53 75 72 61 74 20 47 4a 49 4e 00 62 30 30 31    Surat GJIN.b001
0060   35 33 30 33 34 30 30 31 30 31 30 33 30 33 36 33   5303400101030363
0070   30 33 30 33 30 33 30 33 31 33 32 33 33 33 34 30   0303030313233340
0080   30 31 32 33 34 33 30 33 30 33 36 33 30 33 30 33   0123430303630303
0090   30 33 30 33 31 33 31 33 39 33 37                  03031313937
So what you want is the data in the right hand column e.g. 5303400101030363
to actually be in the left hand hex data
53 03 40 01 01 03 03 63

```
String data = "5303400101030363";// field data that you want to set // strbcd it to get it in the form thats expected   System.out.println(ISOUtil.hexdump(ISOUtil.str2bcd(data, true)));
//0000 53 03 40 01 01 03 03 63 S.@....c // this is what gets output m.set(63, ISOUtil.str2bcd(data, false));
            System.out.println(ISOUtil.hexdump(m.pack()));

```

final sysout
So the field 63 data is the 00 from the first line and the 08 to 63 (this is just a partial/snippet of the dump to explain)

```
0010 09 44 17 09 06 30 30 31 30 30 30 30 31 30 37 00 .D...0010000107. 0020 08 53 03 40 01 01 03 03 63 .S.@....c

```
So now the data is being set as binary.

-chhil

shivjanam sonkar

unread,
Sep 6, 2018, 2:31:01 AM9/6/18
to jPOS Users
Thank you so much sir ..:)
now it's working...:)
thanks again

chhil

unread,
Sep 6, 2018, 8:56:37 PM9/6/18
to jpos-...@googlegroups.com
Great.
Best of luck!

-chhil

chhil

unread,
Sep 8, 2018, 1:37:03 AM9/8/18
to jpos-...@googlegroups.com

 I have the same problem as you,
can you please tell me how you have parse the subfield of data element 63,,
It will be very helpful if you share the snippets of XML.
Thank you.

 
You treat the field as a string and parse it out. Thats the method I would recommend.

Parse the data string and extract subfields from it using java or jpos ISOUtil methods.
Your data is in the LTV format->, length, tag (you call it data set id) and value (you call it data)
You can write a code that loops through the LTV structures and create a java map of tag(java map key) value. This is equivalent to jpos' unpack.
Similarly you can write code that sets up a tag value java map, iterate through it and create a string in the required LTV format that can be set in the messages that you send out (equivalent to jpos' pack() method.

This is one of the ways to do it, doesn't loop or do anything fancy, just extracts the data for you.

    public static void unpack() {

        //hex = iso.get(63);
        String hex = "0059373164936214B536593825723816672376353674060527657133360352057072333675747196717649843336B12872655275303317449649353074";
        int len = Integer.parseInt(hex.substring(0, 4)) * 2;
        System.out.println("length :" + len
                + "( its x 2 as data is in hex, each is represented by 2 characters in the string");
        String hexdata = hex.substring(4, 4 + len);// exclude the 0059 and get
                                                   // the remainder data
        System.out.println("hexData :" + hexdata);
        // Dataset id 3731 is ascii hex representation of 71
        String datasetID = new String(ISOUtil.hex2byte(hexdata.substring(0, 4)));
        System.out.println("datasetID :" + datasetID);
        String dataForDatasetID = hexdata.substring(4);
        System.out.println("dataForDatasetID :" + dataForDatasetID);

    }
Output

length :118( its x 2 as data is in hex, each is represented by 2 characters in the string
hexData :373164936214B536593825723816672376353674060527657133360352057072333675747196717649843336B12872655275303317449649353074
datasetID :71
dataForDatasetID :64936214B536593825723816672376353674060527657133360352057072333675747196717649843336B12872655275303317449649353074
-chhil
Reply all
Reply to author
Forward
0 new messages