8)
toy...@gmail.com wrote:
> by the follow program
> m.set (new ISOField (0, "1800"));
> m.set (new ISOField (11, "101"));
> m.set (new ISOField (37, "a"));
> m.set (new ISOField (60, "1234"));
> System.out.println(ISOUtil.dumpString(b));
>
> resule is : 18000020000008000010000101a 0041234
>
> but when i try to unpack error happen:
> org.jpos.iso.ISOException: field packager '24' is null
> at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:230)
> at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:342)
What are you trying to unpack?
The result of the pack or something else?
From the code given below, can I assume you are also converting the
String into a byte array using ISOUtil.hex2byte and then the unpack of
the byte[] is failing?
If so, I would expect that as you have damaged the message entirely!
>
> and when
>
> GenericPackager p = new GenericPackager("base1.xml");
> InputStream in = new FileInputStream(visamsg.DAT");
> int nbytes = in.available();
> // Read in input file and strip any training white space
> byte[] hexbytes = new byte[nbytes];
> in.read(hexbytes, 0, nbytes);
> while (Character.isWhitespace((char) hexbytes[nbytes - 1]))
> nbytes--;
You should not throw anything away, spaces have just as much right to be
at the end of a message as any other character. You should take care to
preserve the whole message and not add (spaces) or take anything away.
> // Convert it to a byte array
> byte b[] = ISOUtil.hex2byte(hexbytes, 0, nbytes / 2);
Why do you want to do this conversion? Unless you are saving the
character message in a hex format, this breaks it.
You are failing to distinguish between character and hex and getting
yourself very confused. Take a deep breath and check what you are
trying to do please?
> // And upack it into an ISOMsg
> ISOMsg msg = new ISOMsg();
> msg.setPackager(p);
> msg.unpack(b);
> error is:
> java.lang.ArrayIndexOutOfBoundsException: 24
> at org.jpos.iso.ISOUtil.hex2BitSet(ISOUtil.java:576)
> at org.jpos.iso.IFA_BITMAP.unpack(IFA_BITMAP.java:68)
> at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:214)
> at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:342)
> at examples.genericpackager.Test.main(Test.java:51)
>
> how can i do to parse :18000020000008000010000101a 0041234
msg.unpack("18000020000008000010000101a 0041234".getBytes());
might do what you need, but I am not certain, as it is not obvious to me
what you are trying to achieve.
--
Mark
I do think unnecessary hex conversions are causing the problems.
--
Mark