我使用 ISO 8583 v87 创建了一条消息!但是当解析它时,我得到不同的参数值。问题是什么?是否为Hex.encodeHexString
import org.apache.commons.codec.binary.Hex;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
public class ParseISOMessage {
static org.jpos.iso.packager.ISO87APackager packager;
public static void main(String[] args) throws IOException, ISOException {
String data = createMSG();
// Create Packager based on XML that contain DE type
packager = new org.jpos.iso.packager.ISO87APackager();
// Create ISO Message
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.unpack(data.getBytes());
// print the DE list
logISOMsg(isoMsg);
}
private static void logISOMsg(ISOMsg msg) {
System.out.println("----ISO MESSAGE-----");
try {
System.out.println(" MTI : " + msg.getMTI());
for (int i=1;i<=msg.getMaxField();i++) {
if (msg.hasField(i)) {
System.out.println(" Field-"+i+" ("+packager.getFieldPackager(i).getDescription()+") : "+msg.getString(i));
}
}
} catch (ISOException e) {
e.printStackTrace();
} finally {
System.out.println("--------------------");
}
}
private static String createMSG() {
try{
ISO87BPackager packager = new ISO87BPackager();
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.setMTI("0200");
isoMsg.set(2, "1234567890123456");
isoMsg.set(3, "000000");
isoMsg.set(4,"000000001234");
isoMsg.set(7, "0413135553");
isoMsg.set(11, "000091");
isoMsg.set(12, "135553");
isoMsg.set(13, "0413");
isoMsg.set(25, "14");
isoMsg.set(32, "5816720610");
isoMsg.set(35, "1234567890123456=9505146000000000000");
isoMsg.set(37, "000000000000");
isoMsg.set(41,"55555555");
isoMsg.set(49,"123");
isoMsg.set(52,"1A2B3C4D5E6F7012");
isoMsg.set(64,"ABCDEF0123456789");
byte[] b = isoMsg.pack();
System.out.println("**"+Hex.encodeHexString(b)+"**");
return Hex.encodeHexString(b);
}
catch(Exception ex) {
ex.printStackTrace();
return "";
}
}
}
例如,我将PIN DATA设置为ABCDEF0123456789
,但是在解析创建的消息时,PIN DATA是0353535353535353
。