gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 05:38:29 35 4
gpt4 key购买 nike

我正在做一个项目,这个错误一直让我头疼。我正在利用 Java J8583 库构建 ISO8583 消息并发送给远程服务器。服务器的响应是一个十六进制值:5452414E53414354494F4E204552524F52,转换为 ASCII 时:传输错误。

// 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();
}
}

我期待 ISOMessage 返回错误:

INFO: 08002238000000800000567YUY0515135835Q56U46135835051520390013

INFO: Received response: 5452414E53414354494F4E204552524F52

INFO: IsoMessage: null

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

5452414E53414354494F4E204552524F52

最佳答案

如果没有更大的项目背景和要打包的每个字段的值,很难说,但您的请求看起来很奇怪。 STAN(字段 11)应该是数字,但包含字母。另外,您应该检查终端 ID(字段 41)的编码,因为它可能是直接构建的 8 字节,但在某些系统中我看到使用十六进制编码的 16 字节。

关于java - 如何修复Java ISO8583套接字错误: TRANSMISSION ERROR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56152111/

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