2 Jul 14:43
Unpacking issue while receiving iso response
From: santhoshvee <santhoshvee@...>
Subject: Unpacking issue while receiving iso response
Newsgroups: gmane.comp.java.jpos.devel
Date: 2008-07-02 12:47:54 GMT
Subject: Unpacking issue while receiving iso response
Newsgroups: gmane.comp.java.jpos.devel
Date: 2008-07-02 12:47:54 GMT
Hi
Please find below an issue we have faced using jpos 1.4.0. FYI:
Upgradation to 1.6 is currently not an option.
Question:We are facing an issue while unpacking an iso response:
This approach uses, Creating an iso object,packing it to get the
bitmap, convert the bitmap to a hex string, open a socket and send it
out. Upon receiving the response from the same socket read the bitmap
and unpack into an iso object.
We are able to send the message to the server and the server is able
to read our request. However, the response from the server cannot be
unpacked by us.
Also this approach is not scalable, since we are using only the
packaging functionality of jpos and not the channels. Please let me
know if the same hex string (bitmap) can be sent to the receiving
server over a channel e.g. NACChannel so that jpos handles the
conversion to hexstring, packing and unpacking headaches?
Find below the code which was used to send bitmap (hex converted) over
a TCP socket.
// Creating the ISO object
ISOPackager packager = new BASE24Packager();
ISOMsg iso = new ISOMsg();
iso.setPackager(packager);
iso.setMTI("0210");
iso.set(2,"1800000000000000");
iso.set(3,"020000");
iso.set(4, "000000000000");
iso.set(11,"000263");
iso.set(12, "195816");
iso.set(13, "0701");
iso.set(14, "1211");
iso.set(24,"0999");
iso.set(39,ISOUtil.hexString("00".getBytes()));
iso.set(41,ISOUtil.hexString("98311234".getBytes()));
// Packing it
byte[] b = iso.pack();
String temp = ISOUtil.dumpString(b);
temp = "01026002220000" + temp; // appending the header
// Convert to hex string
String dump = new String(hexFromString(temp));
// Send it over TCP socket
Socket socket = new Socket("128.5.22.14", 3200);
PrintWriter out = new PrintWriter(socket.getOutputStream(),true);
BufferedInputStream bi = new BufferedInputStream(socket.getInputStream());
out.println(dump);
// Read the response
String str = "";
byte buf[] = new byte[2048];
int len = 0;
while(true) {
len = bi.read(buf, 0, buf.length);
if(len == -1)
break;
str = new String(buf,0,len);
}
// Unpacking it
String response = ISOUtil.hexString(buf,0,buf.length);
response = ISOUtil.dumpString(response.getBytes());
ISOMsg res = new ISOMsg();
res.setPackager(packager);
int i = res.unpack(response.getBytes());
// Output
expected response string:
0210203C01000 E80 000000000000026309540407021211 0999
38313834303432343034303131353731393330303938333131323334
found response string:
0210203C01000 E20AC000000000000026309540407021211 092122
38313834303432343034303131353731393330303938333131323334
I Have put spaces in the string to show you the areas of difference.
Please suggest what we might be going wrong.
Thanks and Regards
Radhakrishna
------------------------------------
RSS Feed