簡體   English   中英

j8583:ISOMessage解析器未按預期產生輸出

[英]j8583: ISOMessage Parser not producing output as expected

我正在使用j8583 iso解析器來解析ISO消息。

“ 0800A020 00000080 00100400 00000000 00000000 00000001 32393131 30303031 00105445 5354204D 45535347 0301”

下面是我的代碼。

import com.solab.iso8583.IsoMessage;
import com.solab.iso8583.IsoValue;
import com.solab.iso8583.MessageFactory;
import com.solab.iso8583.parse.ConfigParser;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.text.ParseException;

    public class ISOUtility {

        private static BufferedReader reader;

        private static String getMessage() throws IOException {
            if (reader == null) {
                reader = new BufferedReader(new InputStreamReader(System.in));
            }
         //   System.out.println("Paste your ISO8583 message here (no ISO headers): ");
            return "08002020 00000080 00000000 00000001 32393131 30303031";
        }

        public static void main(String [] args) throws IOException, ParseException {
         // System.out.println("Hello");
            final MessageFactory<IsoMessage> mf = new MessageFactory<IsoMessage>();

           if (1 == 0) {
            //   System.out.println("Hello2");

            //  ConfigParser.createFromClasspathConfig("j8583.xml");
                ConfigParser.configureFromDefault(mf);

            }  else {
                System.out.println("Hello3");
                String path="C:\\Users\\DELL\\workspace\\SolabParser\\j8583.xml";
                if (System.console() != null) {
                    System.console().printf("Attempting to configure MessageFactory from %s...%n", path);

                }
                System.out.println("Messagefactory is done");
                String url = "C:\\Users\\DELL\\workspace\\SolabParser\\j8583.xml";
                if (url.contains("://")) {
                    System.out.println("else ");

                    ConfigParser.configureFromUrl(mf, new URL(args[0]));
                } else {
                    System.out.println("else ");
                    ConfigParser.configureFromUrl(mf, new File(path).toURI().toURL());
                }
            }
            //Now read messages in a loop
            String line = getMessage();
          //  while (line != null && line.length() > 0) {

            mf.setIgnoreLastMissingField(true);
                System.out.println(mf.getIgnoreLastMissingField());

                IsoMessage m = mf.parseMessage(line.getBytes(), 0);

                System.out.println("Hello5");
                if (m != null) {
                    System.out.printf("Message type: %04x%n", m.getType());
                    System.out.println("FIELD TYPE    VALUE");
                    for (int i = 2; i <= 128; i++) {
                        IsoValue<?> f = m.getField(i);
                        if (f != null) {
                            System.out.printf("%5d %-6s [", i, f.getType());
                            System.out.print(f.toString());
                            System.out.println(']');
                        }
                    }
                }
                line = getMessage();
         //   }
        }

但是我得到的輸出不正確。

Message type: 0800
FIELD TYPE    VALUE
    3 ALPHA  [000000]
   11 NUMERIC [00 000]
   41 NUMERIC [00001 32393131 3]
   60 LLLVAR [3031 00105445 5354204D 4553534]
   70 NUMERIC [7 0]

除字段3外,其他所有數據均不正確。

如果我對數據空間進行任何更改,則會拋出**錯誤:**

LLLVAR字段60的數據不足

任何建議都可以解決這個問題。

謝謝。

正如我在評論中回答的那樣:

1)從消息緩沖區中刪除空格。

2)檢查您的消息格式配置文件。

在您的情況下,看起來字段60的長度為4個字符。 即LLLLVAR。

---
msg:#"0800A0200000008000100400000000000000000000000001323931313030..0301" 
- MTI: "0800" # Message Type ID. // Network management request
- DE000: "A020000000800010" # Primary bitmap // 1.3.11.41.60.
- BM0:#"0400000000000000000000000001323931313030303100" # Fields at Primary Bitmap
  - DE001: "0400000000000000" # Secondary bitmap // 70.
  - DE003:#"000000" # PC
    - S01: "00" # Transaction Code. // Purchase of goods or services
    - S02: "00" # Account, from. // Standard purchase
    - S03: "00" # Account, to. // Standard purchase
  - DE011: "000001" # STAN. // 1
  - DE041: "3239313130303031" # CATI. // "29110001"
  - DE060:#"001054455354204D45535347"
    - len: "0010" // 10
    - val: "54455354204D45535347" // "TEST MESSG"
- BM1:#"0301" # Fields at Secondary Bitmap
  - DE070: "0301" # Network management information code // 301 - Echo test

暫無
暫無

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

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