how to construct ISO8583 message header for ascii channel and iso93ascii packager in jpos?

AJAY picture AJAY · Feb 5, 2016 · Viewed 9k times · Source

I am trying to create an ISO8583 message using JPOS in java using the ASCII channel to send the message and iso93ascii packager to pack the ISO message.

But after sending the message I am getting invalid header error from the server.

So my question is what is the header made up of exactly and how do I frame my header for MTI value 1200.

ISOMsg.setHeader("HEADER".getBytes());

How should I frame up my HEADER?

New Development :

After taking a look at the server configuration I need to send the header prepended by the length of the ISO8583 message(2 byte length in hex converted to bytes). How can I do this using JPOS? Also am not able to set anything using channel.setHeader("xxx").getBytes()).

How do I see what raw message is being sent from my terminal to the server.

Here are some of the excerpts from the code

Deploy files

filename : 10_clientsimualtor_channel.xml

<?xml version="1.0" ?>
<channel-adaptor name='jpos-client-adaptor'
    class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.ASCIIChannel" logger="Q2"
          packager="org.jpos.iso.packager.ISO93APackager" header= "ISO026000075">

  <property name="host" value="xxx.xx.xx.xx" />
  <property name="port" value="xxxxx" />
</channel>
<in>jpos-client-send</in>
<out>jpos-client-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

Code :

packager = new ISO93APackager();

            ISOMsg m = new ISOMsg();
            m.setPackager(packager);
            System.out.println(packager);

            m.setHeader("ISO026000075".getBytes());
             System.out.println("Head err..........."+newString(m.getHeader()));

            Date now = new Date();

            m.setMTI("1200");
            m.set(2,"xx");
            m.set(3,"xxxxx");
            m.set(4,"000000010000");
            m.set(11,"214491");
            m.set(12,"160203");

            m.set(123, "xxxxxx");
            m.set(125, "xxxx");

           byte b[] = m.pack();
           System.out.println("\n\n\n\nPACKAGER =====------"+m.getPackager());
           System.out.printf("\n\n\n\nMessage ===== %s",new String(b));

            System.out.println("\n\n\n"+ISOUtil.hexdump(b));return m;

Answer

apr picture apr · Feb 7, 2016

You can set your header at the channel level (i.e. channel.setHeader("xxx").getBytes()) or set it on a per-message level (i.e. m.setHeader("xxx".getBytes())).

It is important that the channel knows the header length at receive time, so even if you use per message header, you should set a dummy header at the channel level as well.

Using Q2 and the ChannelAdaptor or QServer components will make your life really easier. Take a look at http://jpos.org/doc/proguide-draft.pdf