[英]Appending length in hex of 2 bytes two Iso8583 message using JPOS
I am using JPOS to send a 0800.network request.我正在使用 JPOS 发送 0800.network 请求。 But the problem is that header length of 2 bytes is not getting appended to my message.但问题是 header 长度为 2 个字节没有附加到我的消息中。 The length of the message if 42 but adding the header of 2 bytes should make it 44. TCP DUMP:如果消息的长度为 42,但添加 2 个字节的 header 应该使它成为 44。TCP DUMP:
length 42
0x0000: 4500 005e 4448 4000 4006 8842 0a14 5140 E..^DH@.@..B..Q@
0x0010: 0a5f 085d 952e 30c8 5cdb c683 49e6 692d ._.]..0.\...I.i-
0x0020: 8018 01f6 6e60 0000 0101 080a 0775 0600 ....n`.......u..
0x0030: 889f a492 3038 3030 8220 0100 0000 0000 ....0800........
0x0040: 0400 0000 0000 0000 3132 3234 3139 3035 ........12241905
0x0050: 3136 3132 3033 3437 3030 3130 3033 16120347001003
Since my message is of 42 length, 002A should be append in hex dump.由于我的消息长度为 42,因此 002A 在十六进制转储中应该是 append。
The message should be:消息应该是:
My Code:
BaseChannel channel = new NACChannel(packager, null);
channel.setHost("xx.xx.xx.xx", xxxxx);
channel.connect();
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.setMTI("0800");
isoMsg.set(7, "1224190516");
isoMsg.set(11, "120347");
isoMsg.set(24, "001");
isoMsg.set(70, "003");
byte[] send_PackedRequestData = isoMsg.pack();
channel.send(send_PackedRequestData);
How can i append the length of the message to the start so it become我怎样才能将消息的长度设为 append 使其变为
002A0800................1224190516120347001003
Use String.format("%04x%s", strIsoMsg.length()/2, strIsoMsg)
.使用String.format("%04x%s", strIsoMsg.length()/2, strIsoMsg)
。
I provide you a pattern code which you can use this pattern for sending message.我为您提供了一个模式代码,您可以使用该模式发送消息。 the这
ISO87BPackager packager = new ISO87BPackager();
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.setMTI("0800");
isoMsg.set(3, "000000"); //PROCESSING CODE
isoMsg.set(4, strAmount); //AMOUNT, TRANSACTION
...
...
...
byte[] b1 = isoMsg.pack();
isoMsg.set(64, MAC.calcMac(b1));
byte[] b2 = isoMsg.pack();
strIsoMsg = "700800900" + new String(Hex.encodeHex(b2));
String msgHexWithLen = String.format("%04x%s", strIsoMsg.length()/2, strIsoMsg);
byte[] bytes = IsoParser.hexStringToByteArray(msgHexWithLen);
...
...
...
Socket socket = new Socket();
socket.connect(new InetSocketAddress("x.y.z.w", 7151), 5000);
socket.setSoTimeout(30000);
socket.getOutputStream().write(bytes, 0, bytes.length);
socket.getOutputStream().flush();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.