Dear All,
We are developing a client application that should communicate with the Utiba Uchoose Server. According to the Utiba spec we have to send,
2-byte length header in Binary format (Network byte order)
(Note: this length header denotes the number of bytes in the message body only)
AND
Message body in ASCII format.
Inorder to communicate with the server we developed a sign on application using jPos. But the response is null. I am providing the code we have developed.
package lk.dialog.ezi.api;
import java.util.Date;
import java.io.PrintStream;
import org.jpos.util.*;
import org.jpos.iso.*;
import org.jpos.iso.packager.*;
import org.jpos.iso.channel.ASCIIChannel;
import org.jpos.iso.header.BaseHeader;
import java.nio.*;
public class SignOnTest implements Runnable {
ASCIIChannel channel;
ISOMUX mux;
public void setupMUX () {
ISOPackager packager = new ISO87APackager();
channel = new ASCIIChannel("192.168.70.82", 17001, packager);
mux = new ISOMUX (channel);
Thread t = new Thread (mux);
t.start();
}
public void run () {
ISOMsg m = new ISOMsg();
try{
m.setMTI("0800");
m.set(new ISOField(7, ISODate.getDateTime(new Date())));
m.set(new ISOField(11, "000001"));
m.set(new ISOField(70, "061"));
m.set(new ISOField(100, "123456"));
m.setPackager(new ISO87APackager());
byte[] messageBody=m.pack();
short messageLength=(short)messageBody.length;
ByteBuffer bb=ByteBuffer.allocate(2);
bb.putShort((short)messageLength);
bb.flip();
byte[] header=bb.array();
BaseHeader bh=new BaseHeader(header);
m.setHeader((ISOHeader)bh);
ISORequest req = new ISORequest(m);
mux.queue(req);
ISOMsg res = req.getResponse(60*1000);
if (res != null) {
res.dump(System.out, "");
System.out.println(res.getString(39));
}
else{
System.out.println("Response is null");
}
mux.showCounters(System.out);
} catch (ISOException e) {
e.printStackTrace();
}
}
public static void main (String args[]) {
SignOnTest test = new SignOnTest();
test.setupMUX ();
(new Thread(test)).start();
}
}
############Output Result##########
Response is null
Connections: 1
TX messages: 1
TX expired: 0
TX pending: 0
RX messages: 0
RX expired: 0
RX pending: 1
RX unmatched: 0
RX forwarded: 0
Please help me to get around this problem. Thanks in advance.