I am new to developing with iso 8583, I need to add a header before the iso message. but I implement them this way and the same is not added to the message header. What am I doing wrong? I hope you can help me.
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()));
when showing the iso message to be sent, the header is not observed
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
Message sent: 0800822000000000000004000000000000001011110140047478401
the message should be sent as follows: ISO0080000990800822000000000000004000000000000001011110140047478401
I am using the following configuration:
<?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"/>
fields that are sent in the message:
<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>
While you can override the header used by a channel by calling
ISOMsg.setHeader, the channel still needs a placeholder header in order to know how many bytes it needs to read, at receive time.In your case, the problem is ASCIIChannel is not the right channel for your interchange. ASCIIChannel does not support a header. Based on the content I see, perhaps you need to use BASE24TCPChannel and set the header on it.
When using jPOS, things are quite easier if you use Q2 (that you can run standalone or from your preferred application (SpringBoot, Quarkus, JBoss/Wildfly, etc.).