我正在尝试使用 JPOS 库来打包/解压缩 ISO8583-1987 消息。
我对格式有问题,在互联网上找不到任何运行示例。
有人能给我一个解压缩十六进制消息的运行示例吗,因为有很多ASCII消息的示例,但这不是我需要的。
感谢大家抽出时间
朱利安
我假设你有一个十六进制字符串来表示字符串中的消息,在这种情况下你必须将它转换成一个字节数组。
例如,假设您将字符串作为main的参数。无论如何,您必须知道该十六进制表示中包含的iso消息的格式。例如,如果消息是二进制的,则必须选择ISO87BPackager;如果消息是ascii的,则需要选择ISO87APackager。
import org.jpos.iso.packager.ISO87BPackager;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
public class ParseISOMsg {
public static void main(String[] args) throws ISOException {
String hexmsg = args[0];
// convert hex string to byte array
byte[] bmsg =ISOUtil.hex2byte(hexmsg);
ISOMsg m = new ISOMsg();
// set packager, change ISO87BPackager for the matching one.
m.setPackager(new ISO87BPackager());
//unpack the message using the packager
m.unpack(bmsg);
//dump the message to standar output
m.dump(System.out, "");
}
}
例如,如果调用<code>java-cp。:jpos.jar ParseISOMsg 080000200000008000001234563132333435363738它应该打印:
<isomsg>
<!-- org.jpos.iso.packager.ISO87BPackager -->
<field id="0" value="0800"/>
<field id="11" value="123456"/>
<field id="41" value="12345678"/>
</isomsg>