我正在使用j8583 库来构建 iso8583 消息。我想将 DE96 元素值设置为二进制数据的十六进制。据我了解,该值应转换为二进制,然后转换为十六进制。很像 BitMap 值。我没有找到任何使用 j8583 API 实现这一目标的方法。我尝试过 ISOType.BINARY 类型,但没有给出所需的值。
请看以下代码
package j8583.example;
import java.io.IOException;
import java.util.Date;
import com.solab.iso8583.IsoMessage;
import com.solab.iso8583.IsoType;
import com.solab.iso8583.MessageFactory;
import com.solab.iso8583.parse.ConfigParser;
import com.solab.iso8583.util.HexCodec;
public class MsgSender0800 {
public static void main(String[] args) {
try {
MessageFactory mfact = ConfigParser.createFromClasspathConfig("j8583/example/config.xml");
IsoMessage msg = mfact.newMessage(0x800);
msg.setValue(7, new Date(), IsoType.DATE10, 10);
msg.setValue(96, "123456", IsoType.BINARY, 6);
/* I want DE 96 value similar to the output of this code
String test = "123456";
String encoded = HexCodec.hexEncode(test.getBytes(), 0, test.length());
System.out.println(encoded);
System.out.println(new String(HexCodec.hexDecode(encoded)));
*/
String strMsg = new String(msg.writeData());
System.out.println(strMsg);
} catch (IOException e) {
e.printStackTrace();
}
}
}
上面的代码打印以下 iso 消息
08008200000000000800040000010000000002190926080000000000000000000123456000000
请查看由 生成的最后 12 个字节,msg.setValue(96, "123456", IsoType.BINARY, 6);
而不是上面的消息我想构建以下消息
08008200000000000800040000010000000002190926080000000000000000000313233343536
最后 6 个字节是十六进制编码值。
ISO.BINAY 还附加了额外的“0”,即带有msg.setValue(96, "123456", IsoType.BINARY, 6);
,它产生123456000000
而不是123456
我想知道是否有人使用此 API 完成了它。否则,我必须在其上添加某种包装器才能添加此功能。
以下是xml配置
<template type="0800">
<field num="53" type="NUMERIC" length="16">00</field>
<field num="70" type="NUMERIC" length="3">000</field>
</template>
我对图书馆很陌生。谁能帮我理解。
谢谢