简体   繁体   English

如何在j8583中生成ISO消息

[英]How to generate an ISO message in j8583

I have text data, 我有文字数据,

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

I need to generate an ISO Message with bitmap fields using j8583 project. 我需要使用j8583项目生成一个带位图字段的ISO消息。

I have tried parsing a isomesssage, but I do not know how to generate an ISO Message. 我曾尝试解析ismessssage,但是我不知道如何生成ISO消息。

Note: I know that this can be done with jpos, but I need to do it with j8583. 注意:我知道可以使用jpos来完成,但是我需要使用j8583来完成。

I have created below program. 我创建了下面的程序。

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);

}

I have got below output. 我有下面的输出。

V0080¢ € 00000010201245030000013239313130303031001054455354204D455353470301 V0080¢€00000010201245030000013239313130303031001054455354204D455353470301

This output doesn't have bitmap values, and have some unwanted values at start. 此输出没有位图值,并且在开始时具有一些不需要的值。

Can someone please help with this? 有人可以帮忙吗?

Thanks. 谢谢。

The following Java code prints 0200A220000000800010040000000000000000000010240507450000013239313130303031001054455354204D455353470301 , in which you can see the bitmap information. 以下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());
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM