I have a web service that accepts this as payload :
{
"MTI": "0100",
"2": "4655206331051889",
"3": "000000",
"4": "000000012300",
"7": "0321054133",
"11": "001205",
"14": "0325",
"18": "5399",
"22": "022",
"25": "00",
"35": "2312312332",
"37": "206305000014",
"41": "29110001",
"42": "1001001",
"49": "840",
"transactionid": "12",
"co-ordinates": "3042304,293572945"
}
This is the code that pack this and generates the iso message representation :
for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
if (entry.getKey().equals("transactionid")) {
msg.set(6, entry.getValue().toString());
} else if (entry.getKey().equals("MTI")) {
msg.setMTI(entry.getValue().toString());
} else if (entry.getKey().equals("co-ordinates")) {
String[] coordinates = entry.getValue().toString().split(",");
msg.set(57, coordinates[0]);
msg.set(58, coordinates[1]);
} else msg.set(Integer.parseInt(entry.getKey().toString()), entry.getValue().toString());
}
msg.setPackager(new ISO87BPackager());
byte[] packedMsg = msg.pack();
System.out.println(ISOUtil.hexdump(packedMsg));
This is the Result :
0000 01 00 76 24 44 80 28 C0 80 C0 16 46 55 20 63 31 ..v$D.(....FU c1
0010 05 18 89 00 00 00 00 00 00 01 23 00 00 00 00 00 ..........#.....
0020 00 12 03 21 05 41 33 00 12 05 03 25 53 99 00 22 ...!.A3....%S.."
0030 00 10 23 12 31 23 32 32 30 36 33 30 35 30 30 30 ..#.1#2206305000
0040 30 31 34 32 39 31 31 30 30 30 31 31 30 30 31 30 0142911000110010
0050 30 31 20 20 20 20 20 20 20 20 38 34 30 00 07 33 01 840..3
0060 30 34 32 33 30 34 00 09 32 39 33 35 37 32 39 34 042304..29357294
0070 35 5
Now i want to exclude the first column which starts with 0000 and the forth comlumn Which looks like encryption or something like that ... So what i expect to have at the end is the start of the second column to the end right before the fourth column ...
Expected output :
01007624448028C080C016465520633105188900000000000001230000000000001203210541330012050325539900220010231231233232303633303530303030313432393131303030313130303130303120202020202020203834300007333034323330340009323933353732393435
Thanks in advance
The ISOUtil.hexdump
method you are using here appears to return a human-readable representation of the data that is passed in. You should search the same library, or another library, to convert the byte[]
to a hexadecimal string.
There are some good options in the answers to this question: How to convert a byte array to a hex string in Java?
To elaborate:
The three columned output you are seeing there is a traditional representation of hexadecimal data: The first column is the hexadecimal/binary address of the first byte on the line; the second column is the data itself, in hex, represented as space-separated bytes; the third column shows the ASCII representation of the bytes on the line. Some of these, mostly characters below 0x21
are non-printable, and thus represented only by a dot (.
) within this representation.
This method of examining binary data is very common in utilities like hex editors. Indeed there is a POSIX/BSD utility, hexdump
, which displays this rough format.