簡體   English   中英

如何在j8583中生成ISO消息

[英]How to generate an ISO message in j8583

我有文字數據,

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

我需要使用j8583項目生成一個帶位圖字段的ISO消息。

我曾嘗試解析ismessssage,但是我不知道如何生成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());
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM