我是新的发展与iso 8583,我需要添加一个标头前的iso消息。但我用这种方式实现它们,并且不将其添加到消息头中。我做错了什么?我希望你能帮助我。
GenericPackager packager = new GenericPackager("tes1.xml");
// Create a new ISOMsg object using the custom packager
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.setHeader("ISO008000099".getBytes());
isoMsg.setMTI("0800");
isoMsg.set(7, "1011110140");
isoMsg.set(11, "047478");
isoMsg.set(70, "401");
ASCIIChannel c = new ASCIIChannel("localhost", 6000, packager);
c.connect();
c.send(isoMsg);
System.out.println("ISO message : " + new String(isoMsg.pack()));
//System.out.println(new String(isoMsg.pack()));
当显示要发送的iso消息时,不观察报头
0000 30 38 30 30 38 32 32 30 30 30 30 30 30 30 30 30 0800822000000000
0010 30 30 30 30 30 34 30 30 30 30 30 30 30 30 30 30 0000040000000000
0020 30 30 30 30 31 30 31 31 31 31 30 31 34 30 30 34 0000101111014004
0030 37 34 37 38 34 30 31 7478401
已发送消息:0800822000000000000004000000000000001011110140047478401
该信息应按如下方式发送:ISO00800009908008220000000000000004000000000000001011110140047478401
我正在使用以下配置:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager SYSTEM "genericpackager3.dtd">
<!-- ISO 8583:1987 (ASCII) field descriptions for GenericPackager -->
<isopackager>
<header length="12" value =""></header>
<isofield
id="0"
length="4"
name="MESSAGE TYPE INDICATOR"
class="org.jpos.iso.IFA_NUMERIC"/>
<isofield
id="1"
length="16"
name="BIT MAP"
class="org.jpos.iso.IFA_BITMAP"/>
<isofield
id="2"
length="21"
name="PAN - PRIMARY ACCOUNT NUMBER"
class="org.jpos.iso.IFA_LLNUM"/>
<isofield
id="3"
length="6"
name="PROCESSING CODE"
class="org.jpos.iso.IFA_NUMERIC"/>
<isofield
id="4"
length="12"
name="AMOUNT, TRANSACTION"
class="org.jpos.iso.IFA_NUMERIC"/>
和.dtd的配置:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT isopackager (header?,isofield*,isofieldpackager*)>
<!ELEMENT header (#PCDATA)>
<!ATTLIST header
length CDATA #REQUIRED
value CDATA #REQUIRED>
<!ATTLIST isopackager maxValidField CDATA #IMPLIED>
<!ATTLIST isopackager bitmapField CDATA #IMPLIED>
<!ATTLIST isopackager thirdBitmapField CDATA #IMPLIED>
<!ATTLIST isopackager firstField CDATA #IMPLIED>
<!ATTLIST isopackager emitBitmap (true|false) #IMPLIED>
<!ATTLIST isopackager headerLength CDATA #IMPLIED>
<!-- isofield -->
<!ELEMENT isofield (#PCDATA)>
<!ATTLIST isofield id CDATA #REQUIRED>
<!ATTLIST isofield length CDATA #REQUIRED>
<!ATTLIST isofield name CDATA #REQUIRED>
<!ATTLIST isofield class NMTOKEN #REQUIRED>
<!ATTLIST isofield params CDATA #IMPLIED>
<!ATTLIST isofield encoding CDATA #IMPLIED>
<!ATTLIST isofield token CDATA #IMPLIED>
<!ATTLIST isofield pad (true|false) #IMPLIED>
<!ATTLIST isofield trim (true|false) #IMPLIED>
<!-- isofieldpackager -->
<!ELEMENT isofieldpackager (isofield*,isofieldpackager*)*>
<!ATTLIST isofieldpackager id CDATA #REQUIRED>
<!ATTLIST isofieldpackager name CDATA #REQUIRED>
<!ATTLIST isofieldpackager length CDATA #REQUIRED>
<!ATTLIST isofieldpackager class NMTOKEN #REQUIRED>
<!ATTLIST isofieldpackager params CDATA #IMPLIED>
<!ATTLIST isofieldpackager token CDATA #IMPLIED>
<!ATTLIST isofieldpackager pad (true|false) #IMPLIED>
<!ATTLIST isofieldpackager packager NMTOKEN #REQUIRED>
<!ATTLIST isofieldpackager emitBitmap (true|false) #IMPLIED>
<!ATTLIST isofieldpackager maxValidField CDATA #IMPLIED>
<!ATTLIST isofieldpackager bitmapField CDATA #IMPLIED>
<!ATTLIST isofieldpackager firstField CDATA #IMPLIED>
<!ATTLIST isofieldpackager headerLength CDATA #IMPLIED>
<!ATTLIST isofieldpackager tagMapper CDATA #IMPLIED>
<!ATTLIST isofieldpackager tagSize CDATA #IMPLIED>
<!ATTLIST isofieldpackager lenSize CDATA #IMPLIED>
<!ATTLIST isofieldpackager swapTagAndLen (true|false) #IMPLIED>
在消息中发送的字段:
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.GenericPackager[tes1.xml] -->
<header>49534F303038303030303939</header>
<field id="0" value="0800"/>
<field id="7" value="1011110140"/>
<field id="11" value="047478"/>
<field id="70" value="401"/>
</isomsg>
2条答案
按热度按时间efzxgjgh1#
虽然您可以通过调用
ISOMsg.setHeader
来覆盖通道使用的标头,但通道仍然需要一个占位符标头,以便在接收时知道需要读取多少字节。在您的情况下,问题是ASCIIChannel不是您交换的正确通道。ASCIIChannel不支持标头。根据我看到的内容,也许你需要使用BASE 24 TCPChannel并在上面设置header。
当使用jPOS时,如果使用Q2(您可以独立运行或从首选应用程序(SpringBoot,Quarkus,JBoss/Wildfly等)运行),事情会变得非常容易。
9nvpjoqh2#
问题是,头不是由打包器处理的,它是由通道处理的,这就是为什么当你打印打包的消息时你看不到。
要查看哪些内容传输到另一端,您需要一个嗅探工具,如tcpdump或Wireshark。或者,因为这是一个测试,你最好使用netcat来看看另一方会收到什么,类似这样:
我添加了
xxd
来显示十六进制转储,但您也可以将输出重定向到一个文件,然后用十六进制查看器/编辑器打开它。在那里,您将看到,除了头部,您还将看到4个长度字节作为ASCII数字。正如apr所说,ASCIIChannel
可能不是你需要的频道。为了在通道级别设置header,并且您需要这样做才能正确地接收响应,这一行应该可以做到这一点: