ISO Message Header Issue - Unpacking Correctly

1,452 views
Skip to first unread message

Foly

unread,
Jan 26, 2013, 4:07:02 PM1/26/13
to jpos-...@googlegroups.com
I have an implementation that has the following requirement:

Header Format: ANS8 [Start Indicator-ANS 3, Protocol Version - N 2, Reject Status - N 3]
In the message below the value "41344D3035303030" is meant to be the header i.e. 'A4M05000'.

However, I have been unable to successfully parse/unpack the ISO message. I currently use PostChannel and GenericPakager.
I defined an XML document containing the ISO field specification for the implementation but yet to successfully unpack the ISO message below.

Kindly assist on possible solution in getting the 0800 message below unpacked accurately.
Thank you.

<log realm="postpack-debug" at="Sat Jan 26 19:21:31 GMT+01:00 2013.46">
  <unpack>
    41344D3035303030303830303832323030303030303030303030303030343030303030303030
30303030303030313236313831343536333336303238303031
    <bitmap>{2, 4, 21, 33, 39, 43}</bitmap>
    <unpack fld="2" packager="org.jpos.iso.IFA_LLNUM">
      <value></value>
    </unpack>
    <unpack fld="4" packager="org.jpos.iso.IFA_NUMERIC">
      <value>000000040000</value>
    </unpack>
    <unpack fld="21" packager="org.jpos.iso.IFA_NUMERIC">
      <value>000</value>
    </unpack>
    <unpack fld="33" packager="org.jpos.iso.IFA_LLNUM">
      <value></value>
    </unpack>
    <unpack fld="39" packager="org.jpos.iso.IFA_NUMERIC">
      <value>00000</value>
    </unpack>
    <unpack fld="43" packager="org.jpos.iso.IFA_LLLCHAR">
      <value>618145633602</value>
    </unpack>
    WARNING: unpack len=63 consumed=59
  </unpack>
</log>
<log realm="post-channel/172.19.10.11:5900" at="Sat Jan 26 19:21:31 GMT+01:00 2
013.62">
  <receive>
    <isomsg direction="incoming">
      <field id="0" value="A4M0"/>
      <field id="2" value=""/>
      <field id="4" value="000000040000"/>
      <field id="21" value="000"/>
      <field id="33" value=""/>
      <field id="39" value="00"/>
      <field id="43" value="618145633602"/>
    </isomsg>
  </receive>

Mark Salter

unread,
Jan 26, 2013, 4:57:10 PM1/26/13
to jpos-...@googlegroups.com
On 26/01/2013 21:07, Foly wrote:

> Kindly assist on possible solution in getting the 0800 message below
> unpacked accurately.
You need to set a header on the Channel I think, so it knows the length...

... channel.setHeader('A4M05000');


but check the form your Channel is expecting ( http://bit.ly/11ZXBru )



--
Mark

Foly

unread,
Jan 26, 2013, 10:03:32 PM1/26/13
to jpos-...@googlegroups.com
Mark,
   Thanks for the the suggestion.
I tried using the following based on the post you sent in your reply but got the same result. I even increased the length by removing the /2 value.

/**
    *      * @param header Hex representation of header
    */
    public void setHeader (String header) {
        super.setHeader (
            ISOUtil.hexString(header.getBytes())
        );
    }
}

I may not be able to set the header to the constant 'A4M05000' as you suggested because the documentations states that the last 3 characters of the header may change as follows:
For standard message – 000
For declined message, it contains the value other than 000 and can take on the following values:
 001 – message is not of the TIC/TCI type
 197 – message contains invalid MAC
 other – number of the ‘bad’ field of the message

Thanks.

Foly

unread,
Jan 27, 2013, 2:44:47 AM1/27/13
to jpos-...@googlegroups.com
I also set the header as suggested but still got the same result.


 public void setHeader (String header) {
        super.setHeader (
            "A4M05000"
        );

Mark Salter

unread,
Jan 27, 2013, 3:47:14 AM1/27/13
to jpos-...@googlegroups.com
On 27/01/2013 03:03, Foly wrote:

> I tried using the following based on the post you sent in your reply but
> got the same result. I even increased the length by removing the /2 value.
You removed the /2?

You might need to specify the value in character hex - or is that what
you mean?


>
> /**
> * * @param header Hex representation of header
> */
> public void setHeader (String header) {
> super.setHeader (
> ISOUtil.hexString(header.getBytes())
> );
> }
> }
This suggests that you need to specify :-

channel.setHeader('41344D3035303030')

which is why I linked to the thread detailing this check.

>
> I may not be able to set the header to the constant 'A4M05000' as you
> suggested because the documentations states that the last 3 characters
> of the header may change as follows:
> For standard message – 000
> For declined message, it contains the value other than 000 and can take
> on the following values:
>  001 – message is not of the TIC/TCI type
>  197 – message contains invalid MAC
>  other – number of the ‘bad’ field of the message
This is not really hardcoding the length, it is simply setting the scope
of the length for the Channel; it will only use it on a send *if* your
ISOMsg does not carry a specific header. On receive it uses the length
to pull the current header bytes off the network.


--
Mark

Foly

unread,
Jan 27, 2013, 6:49:48 AM1/27/13
to jpos-...@googlegroups.com
I specified the value in Hex format as shown below but still got the same result. I have also included the extract of my Channel implementation for review.

  public TWOChannel (ISOPackager p, ServerSocket serverSocket)
        throws IOException
    {
        super(p, serverSocket);
    }
    protected void sendMessageLength(int len) throws IOException {
        serverOut.write (len >> 8);
        serverOut.write (len);
    }
    protected int getMessageLength() throws IOException, ISOException {
        byte[] b = new byte[2];
        serverIn.readFully(b,0,2);
        return (int) (
            ((((int)b[0])&0xFF) << 8) |
            (((int)b[1])&0xFF));

    }
   /**
    *      * @param header Hex representation of header
    */
    public void setHeader (String header) {
        super.setHeader (
                "41344D3035303030"
        );
    }
   



On Saturday, January 26, 2013 10:07:02 PM UTC+1, Foly wrote:

Foly

unread,
Jan 27, 2013, 10:24:15 AM1/27/13
to jpos-...@googlegroups.com
I have been able to get over the header issue. I set the header on the ISO server (header="A4M05000").
I also implemented the setHeader as /**

     *      * @param header Hex representation of header
     */
     public void setHeader (String header) {
         super.setHeader (
                 ISOUtil.hexString(header.getBytes(), 0, header.length()/2)
         );
     }

However, I am having some problems with the packager unpacking the message. Kindly assist to review with possible solution. My sample message can be found below.
Notice that the dump of the message appears different when it gets to the ISO server with additional 30 30 30 30 31  at the end of the message.

The error I get can be seen after the request message.

30383030383233303030303030303030303030303034303030303030303030303030303030313237313631313230303030303030313635313431333031
<log realm="channel.web-channel-adaptor/127.0.0.1:6100" at="Sun Jan 27 16:11:20 WAT 2013.676">
  <connect>
    127.0.0.1:6100
  </connect>
</log>

<log realm="channel.web-channel-adaptor/127.0.0.1:6100" at="Sun Jan 27 16:11:20 WAT 2013.723">
  <send>
    <isomsg direction="outgoing">
      <header>41344D3035303030</header>
      <field id="0" value="0800"/>
      <field id="7" value="0127161120"/>
      <field id="11" value="000000"/>
      <field id="12" value="165141"/>
      <field id="70" value="301"/>
    </isomsg>
  </send>
</log>

Exception:

<log realm="postpack-debug" at="Sun Jan 27 16:11:20 WAT 2013.739">
  <unpack>
    3038303038323330303030303030303030303030303430303030303030303030303030303031
323731363131323030303030303031
    <bitmap>{1, 7, 11, 12, 70}</bitmap>
    <unpack fld="7" packager="org.jpos.iso.IFA_NUMERIC">
      <value>0127161120</value>
    </unpack>
    <unpack fld="11" packager="org.jpos.iso.IFA_NUMERIC">
      <value>000000</value>
    </unpack>
    <iso-exception>
      org.jpos.iso.IFA_NUMERIC: Problem unpacking field 12
      <nested-exception>
      java.lang.ArrayIndexOutOfBoundsException: 53
        at org.jpos.iso.AsciiInterpreter.uninterpret(AsciiInterpreter.java:88)
        at org.jpos.iso.ISOStringFieldPackager.unpack(ISOStringFieldPackager.jav
a:204)
        at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:229)
        at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:322)
        at org.jpos.iso.BaseChannel.receive(BaseChannel.java:531)
        at org.jpos.iso.ISOServer$Session.run(ISOServer.java:123)
        at org.jpos.util.ThreadPool$PooledThread.run(ThreadPool.java:100)
      </nested-exception>
      org.jpos.iso.ISOException: org.jpos.iso.IFA_NUMERIC: Problem unpacking fie
ld 12 (java.lang.ArrayIndexOutOfBoundsException: 53)
        at org.jpos.iso.ISOStringFieldPackager.unpack(ISOStringFieldPackager.jav
a:209)
        at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:229)
        at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:322)
        at org.jpos.iso.BaseChannel.receive(BaseChannel.java:531)
        at org.jpos.iso.ISOServer$Session.run(ISOServer.java:123)
        at org.jpos.util.ThreadPool$PooledThread.run(ThreadPool.java:100)
Nested:java.lang.ArrayIndexOutOfBoundsException: 53
        at org.jpos.iso.AsciiInterpreter.uninterpret(AsciiInterpreter.java:88)
        at org.jpos.iso.ISOStringFieldPackager.unpack(ISOStringFieldPackager.jav
a:204)
        at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:229)
        at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:322)
        at org.jpos.iso.BaseChannel.receive(BaseChannel.java:531)
        at org.jpos.iso.ISOServer$Session.run(ISOServer.java:123)
        at org.jpos.util.ThreadPool$PooledThread.run(ThreadPool.java:100)
    </iso-exception>

--- header ---
    0000  41 34 4D 30 35 30 30 30                           A4M05000

    --- data ---
    0000  30 38 30 30 38 32 33 30  30 30 30 30 30 30 30 30  0800823000000000
0010  30 30 30 30 30 34 30 30  30 30 30 30 30 30 30 30  0000040000000000
0020  30 30 30 30 30 31 32 37  31 36 31 31 32 30 30 30  0000012716112000
0030  30 30 30 30 31                                    00001

Mark Salter

unread,
Jan 27, 2013, 1:45:49 PM1/27/13
to jpos-...@googlegroups.com
On 27/01/2013 11:49, Foly wrote:
> /**
> * * @param header Hex representation of header
> */
> public void setHeader (String header) {
> super.setHeader (
> "41344D3035303030"
> );
> }
>
You added this?

I actually meant to call the method from your setup code instead, this
method I expected to already be there and you would just use it, but not
to worry, perhaps you have solved your setup problem...

--
Mark

Mark Salter

unread,
Jan 27, 2013, 1:56:01 PM1/27/13
to jpos-...@googlegroups.com
On 27/01/2013 15:24, Foly wrote:
> I have been able to get over the header issue. I set the header on the
> ISO server (header="A4M05000").
> I also implemented the setHeader as /**
> * * @param header Hex representation of header
> */
> public void setHeader (String header) {
> super.setHeader (
> ISOUtil.hexString(header.getBytes(), 0, header.length()/2)
> );
> }
>
Again, I don't think you need to add any code to use headers you should
just be able to call the existing methods passing in the correct form
and length data.

> However, I am having some problems with the packager unpacking the
> message. Kindly assist to review with possible solution. My sample
> message can be found below.

> Notice that the dump of the message appears different when it gets to
> the ISO server with additional 30 30 30 30 31 at the end of the message.
What sends the message to this server - what Packager does it use? Are
all your sending/receiving components (each pair) using the same
Channel/Packager and header setup and code (to set the header)?

Where is your message length in this message exchange?

In jPOS terms, the Header follows the length, but is ahead of the MTI,
is your resultant message length from the Channel correct?

You can add a Logger to your Channels to see what bytes are going where.

I'm worried that your code additions are messing the length calculation up.


--
Mark

Foly

unread,
Jan 30, 2013, 10:30:41 AM1/30/13
to jpos-...@googlegroups.com
I tried to unset the header information in my implementation at Server channel but it did not take effect. The code line below was implemented in my filter just before the iOS message is returned.

m.unset(-1);

I would not know why the header still remains unset when message gets to the upstream system.
Kindly assist.

Thanks.

On Saturday, January 26, 2013 10:07:02 PM UTC+1, Foly wrote:

Alejandro Revilla

unread,
Jan 30, 2013, 1:00:01 PM1/30/13
to jpos-...@googlegroups.com

You need to call m.setHeader(null);

--
@apr



--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage.
Please support jPOS, contact: sa...@jpos.org

You received this message because you are subscribed to the  "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users

---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Foly

unread,
Feb 3, 2013, 3:48:21 PM2/3/13
to jpos-...@googlegroups.com
Thanks Alenjandro.

Rejuan Masud Masud

unread,
Jun 6, 2013, 9:56:33 AM6/6/13
to jpos-...@googlegroups.com
Hi Foly,
Have you done with Generic Packager and Post Chanel to connect with TIC? Can you share the packager xml, i need to do the same.
-Regards
Rejuan Masud
Reply all
Reply to author
Forward
0 new messages