gpt4 book ai didi

java - 如何在 j8583 中生成 ISO 消息

转载 作者:行者123 更新时间:2023-11-29 06:53:33 25 4
gpt4 key购买 nike

我有文本数据,

PROCESSINGCODE: 000000
SYSTEMTRACEAUDITNUMBER: 000001
Cardacceptorterminalidentification:3239313130303031
Reservednational:001054455354204D45535347
Networkmanagementinformationcode:0301

我需要使用 j8583 项目生成带有位图字段的 ISO 消息。

我已经尝试解析一个 isomesssage,但我不知道如何生成一个 ISO 消息。

注意:我知道这可以用jpos来做,但我需要用j8583来做。

我已经创建了以下程序。

public static void main(String[] args) {


MessageFactory<IsoMessage> mf = new MessageFactory<IsoMessage>();
try {
//mfact = ConfigParser.createFromClasspathConfig("C:\\Users\\DHEERAJ\\workspace\\j8583.xml");

String path="C:\\Users\\DHEERAJ\\workspace\\j8583.xml";
ConfigParser.configureFromUrl(mf, new File(path).toURI().toURL());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mf.setForceSecondaryBitmap(true);
mf.setUseBinaryBitmap(true);
mf.setAssignDate(true);
mf.setTraceNumberGenerator(new SimpleTraceGenerator((int) (System.currentTimeMillis() % 100000)));
System.out.println("NEW MESSAGE");
IsoMessage m = mf.newMessage(0200);

m.setValue(3, "000000", IsoType.ALPHA, 6);
m.setValue(11, "000001", IsoType.ALPHA, 6);
m.setValue(41, "3239313130303031", IsoType.ALPHA, 16);
m.setValue(60, "001054455354204D45535347", IsoType.ALPHA, 24);
m.setValue(70, "0301", IsoType.ALPHA, 4);

m.setForceSecondaryBitmap(true);

}

我得到以下输出。

V0080¢ € 00000010201245030000013239313130303031001054455354204D455353470301

此输出没有位图值,并且在开始时有一些不需要的值。

有人可以帮忙吗?

谢谢。

最佳答案

以下 Java 代码打印 0200A220000000800010040000000000000000000010240507450000013239313130303031001054455354204D455353470301,您可以在其中查看位图信息。

import com.solab.iso8583.MessageFactory;
import com.solab.iso8583.IsoMessage;
import com.solab.iso8583.IsoType;
import com.solab.iso8583.parse.ConfigParser;
import com.solab.iso8583.impl.SimpleTraceGenerator;
import java.io.File;
import java.io.IOException;

class Sample {
public static void main(String[] args) {
// Check http://j8583.sourceforge.net/javadoc/index.html

MessageFactory<IsoMessage> mf = new MessageFactory<IsoMessage>();

try {
String path="j8583.xml";
ConfigParser.configureFromUrl(mf, new File(path).toURI().toURL());
} catch (IOException e) {
e.printStackTrace();
}

mf.setForceSecondaryBitmap(true);
mf.setUseBinaryBitmap(true);
mf.setAssignDate(true); // This sets field 7 automatically
mf.setTraceNumberGenerator(new SimpleTraceGenerator((int) (System.currentTimeMillis() % 100000)));

IsoMessage m = mf.newMessage(0x200); // You must use 0x200, 0x400, etc.
m.setValue(3, "000000", IsoType.ALPHA, 6);
m.setValue(11, "000001", IsoType.ALPHA, 6);
m.setValue(41, "3239313130303031", IsoType.ALPHA, 16);
m.setValue(60, "001054455354204D45535347", IsoType.ALPHA, 24);
m.setValue(70, "0301", IsoType.ALPHA, 4);
m.setForceSecondaryBitmap(true);

System.out.println(m.debugString());
}
}

关于java - 如何在 j8583 中生成 ISO 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40147480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com