我正在使用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请查看msg.setValue(96, "123456", IsoType.BINARY, 6);生成的最后12个字节,而不是上面的消息,我希望生成以下消息
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>我对图书馆很陌生。有谁能帮我理解一下。
谢谢
发布于 2014-03-05 22:00:21
对于IsoType.BINARY,提供的值应该是byte[],然后在写操作期间将该字节数组转换为十六进制。
https://stackoverflow.com/questions/21821662
复制相似问题