简体   繁体   English

如何修复Java ISO8583套接字错误:TRANSMISSION ERROR

[英]How to fix Java ISO8583 socket error: TRANSMISSION ERROR

I am working on a project and this error have been giving me headache. 我正在研究一个项目,这个错误让我很头疼。 I am making use of Java J8583 library to construct an ISO8583 message and send to a remote server. 我正在使用Java J8583库来构造ISO8583消息并发送到远程服务器。 The server's response is a hex value: 5452414E53414354494F4E204552524F52 which when converted to ASCII: TRANSMISSION ERROR. 服务器的响应是十六进制值:5452414E53414354494F4E204552524F52,当转换为ASCII时:TRANSMISSION ERROR。

// function to construct Message
public IsoMessage createLoadRequest(String tag) {
IsoMessage nManagementMsg = messageFactory.newMessage(0x0800);
Date date = new Date();

String terminalID = new Utils().retrieveTerminalID(); 


nManagementMsg.setField(3, new IsoValue<Object>(IsoType.ALPHA, tag, 6));
nManagementMsg.setField(7, new IsoValue<Object>(IsoType.NUMERIC, utcTime.format(date), 10));
lastTransactionAuditCode = Utils.randomAlphaNumeric(6);
nManagementMsg.setField(11, new IsoValue<Object>(IsoType.NUMERIC, lastTransactionAuditCode, 6)); // System Trace Audit Number
nManagementMsg.setField(12, new IsoValue<>(IsoType.NUMERIC, localTime.format(date), 6));
nManagementMsg.setField(13, new IsoValue<>(IsoType.DATE_EXP, localDate.format(date), 4));
nManagementMsg.setField(41, new IsoValue<Object>(IsoType.ALPHA, terminalID, 8));

return nManagementMsg;
}

//function to make send Message to server
public boolean retrieveData() throws UnsupportedEncodingException {

IsoMessage networkManagementMsg = this.createLoadRequest("567YUY");

String strToSend = new String(networkManagementMsg.writeData());

if (!start()) {
    return false;
}

try {

        logger.info(strToSend);

    outputStream.writeUTF(strToSend);
    IsoMessage response = readMessage();
    final String result = response.getAt(39).toString();

    if (!result.equals("00")) {
        logger.log(Level.WARNING, "Network Management Response contains a non-zero result code {0}", result);
        return false;
    }

    // parse and get required data
    String value = response.getAt(62).toString();
    System.out.println(value);


    return true;
 } catch (Exception ex) {
    logger.severe("Exception while loading terminal info");
    ex.printStackTrace();
    return false;
} finally {
    stop();
}
}

I was expecting an ISOMessage back got error: 我期待一个ISOMessage返回错误:

INFO: 08002238000000800000567YUY0515135835Q56U46135835051520390013

INFO: Received response: 5452414E53414354494F4E204552524F52

INFO: IsoMessage: null

java.io.IOException: Failed to parse iso message string: 

5452414E53414354494F4E204552524F52 5452414E53414354494F4E204552524F52

It's hard to say without larger context of your project and values of each field you want to pack, but your request looks strange. 如果没有更大的项目上下文和要打包的每个字段的值,很难说,但您的请求看起来很奇怪。 STAN (field 11) was supposed to be numeric, but contains alpha. STAN(字段11)应该是数字,但包含alpha。 Also, you should check encoding of Terminal ID (field 41) as it may be 8 bytes directly as you had it built it but in some systems I've seen 16 bytes using hex encoding. 此外,你应该检查终端ID(字段41)的编码,因为它可能是你建立它的8个字节,但在一些系统中我看到16个字节使用十六进制编码。

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

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