0

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>
Andrés Alcarraz
  • 1,570
  • 1
  • 12
  • 21
Raul Roa
  • 21
  • 4

2 Answers2

0

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.).

apr
  • 1,288
  • 7
  • 8
  • Thank you so much for your help. a query where I can get jpos information in relation to Q2. – Raul Roa Jun 19 '23 at 13:45
  • I can now send the header in the iso message. I used the BASE24TCPChannel channel but now to all the messages at the end it adds this 03 in hexadecinal as I can remove it. – Raul Roa Jun 19 '23 at 13:48
0

Thing is, the header is not handled by the packager, it is handled by the channel, that's why you don't see when you print the packed message.

To see what travels to the other side, you need a sniffing tool, like tcpdump or Wireshark. Or, since it is a test, you better use netcat to see what the other side would receive, something like this:

nc -l 6000 | xxd

I added xxd to show a hex dump, but you could also redirect the output to a file and then open it with a hexadecimal viewer/editor. There you will see that in addition to the header you will see 4 length bytes as ASCII digits. As apr said, ASCIIChannel may not be the channel you need.

For setting the header at the channel level, and you'll need to do it to correctly receive the response, this line should do the trick:

channel.setHeader("ISO008000099");
Andrés Alcarraz
  • 1,570
  • 1
  • 12
  • 21
  • Thank you so much for your help. a query where I can get information jpos – Raul Roa Jun 19 '23 at 13:44
  • What kind of information? You have the www.jpos.org main site, and the [jPOS programmers guide](https://jpos.org/doc/proguide-draft.pdf) you have also [tutorials](http://www.jpos.org/tutorials) – Andrés Alcarraz Jun 19 '23 at 17:10