Today, i have new project for creating TCP server and client for electronic financial transaction.
Actually, i feel strange to the requirment because we have to sent xml messaging through an TCP, my big question is WHY DONT YOU USE HTTP??? and my boss said, “we have to coddling the clients!” so i can’t say anything.
I am jPOS ISO8583 framework fanatics, so i want to use jPOS for this project. My big problems is, the messaging is not ISO8583 format, so i have to custom to fits the jPOS framework work flow. Then, i look the sample request, response message and getting a big idea *i think*. I want to Create jPOS Custom XML Channel ISO8583 Format and put the xml message into jPOS ISOMsg class.
So, the only solution is write my own Custom Channel and i have to use XMLPackager because these packager is not specify the bit length or bit type (IFCHAR, IFA_LLLCHAR, etc). The messaging specification is [len][xml_data], so in my mind i have to overide the sendMessageLength(len) and getMessageLength() methods because i need to read message based on length.
The second thing is i have put the xml message into ISOMsg format. In this case, i will overade the send() and receive() methods. The xml message key is on attribute SvcRqId and i need to read the value, and put into bit 11 (STAN) and bit 41 (Terminal Data), so i use SAX library to achieve that.
I just manipulate the byte message data so, it can fits into jPOS framework work flow, here the methods for creating ISOMsg from xml:
[java]
/**
* Create ISOMsg and set the key (bit 11 / 41) based on SvcRqId tag
* @param xmlMsg
* @return ISOMsg
*/
public static ISOMsg createMsg(String xmlMsg){
ISOMsg msg = new ISOMsg();
try {
msg.setMTI(“0200”);
String svcRqId = JposUtil.getXMLAttrValue(xmlMsg, Constant.SVCRQID_TAG);
msg.set(11, JposUtil.subString(svcRqId, 6, true));
msg.set(41, JposUtil.subString(svcRqId, 16, false));
msg.set(126, xmlMsg);
} catch (ISOException e) {
e.printStackTrace();
}
return msg;
}
[/java]
Thats all my post about
Leave a Reply