I’m make JPOS request for iso8583 and use code:
String FileParam = "jpos_fields.xml";
GenericPackager packager = new GenericPackager(FileParam);
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.setMTI("0800");
isoMsg.set(3, "990000");
isoMsg.set(7, "0605144125");
isoMsg.set(11, "000001");
isoMsg.set(24, "831");
isoMsg.set(29, "001");
isoMsg.set(41, "S01JS020");
isoMsg.set(42, "0187490");
isoMsg.recalcBitMap();
BitSet bset = (BitSet) isoMsg.getValue(-1);
TPDUChannel channel = new TPDUChannel();
channel.setHost("127.0.0.1");
channel.setPort(8185);
channel.setPackager(packager);
byte [] TPDU = new byte [5];
TPDU [0] = (byte) 0x68; //0800/0810 only
TPDU [1] = (byte) 0x00;
TPDU [2] = (byte) 0x03;
TPDU [3] = (byte) 0x02;
TPDU [4] = (byte) 0x00;
channel.setTPDU(TPDU);
//channel.pr
channel.connect();
channel.send(isoMsg);
ISOMsg r = channel.receive ();
channel.disconnect ();
BitSet bsetRe = (BitSet) r.getValue(-1);`
And TPDUChannel class:
public class TPDUChannel extends ASCIIChannel {
private static byte[] TPDU = new byte[5];
public static void setTPDU(byte[] b) {
System.arraycopy(b, 0, TPDU, 0, TPDU.length);
}
protected void sendMessageLength(int len) throws IOException {
// write TPDU
if (TPDU != null) serverOut.write(TPDU);
//write ASCIIChannel length
super.sendMessageLength(len);
}
protected int getMessageLength() throws IOException, ISOException {
// skip header
if (TPDU != null) {
byte[] b = new byte[TPDU.length];
serverIn.readFully(b, 0, TPDU.length);
}
// read ASCIIChannel length
return super.getMessageLength();
}
}
It’s work fine and I get an answer, but it’s need to make manual request by socket. I know how to gen isoMsg and send over socket, but really don’t know how to set TPDU. Please, help
Try manual send socket request like JPOS
New contributor
user1786639 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.