in Education by
I am having a challenge. I am using Jpos and I am trying to set field 127 sub-element 033 as well as unpacking it. When packing, seems like its working fine but when trying to unpack I get the following exception. Caused by: org.jpos.iso.ISOException: org.jpos.iso.IFA_LLCHAR: Problem unpacking field 11 (java.lang.NegativeArraySizeException) unpacking field=127, consumed=287 If i comment out the setting of field 127.033 as well as removing the isofield with id = 33 under field 127 in fields.xml everything works well. But when i uncomment the above, the error re-surfaces. Packer: import org.jpos.iso.ISOException; import org.jpos.iso.ISOMsg; import org.jpos.iso.packager.GenericPackager; import java.io.InputStream; import java.text.SimpleDateFormat; public class PackerTest { public static void main(String[] args) throws ISOException { InputStream is = com.melah.Pack.class.getResourceAsStream("/fields.xml"); GenericPackager packager = new GenericPackager(is); ISOMsg isoMsg = new ISOMsg(); isoMsg.setPackager(packager); isoMsg.set(0, "0200"); isoMsg.set(2, "5000000000000000"); isoMsg.set(3, "317000"); isoMsg.set(4, "000000000000"); isoMsg.set(7, new SimpleDateFormat("MMddHHmmss").format(1221133630)); isoMsg.set(11, "594972"); isoMsg.set(12, "153630"); isoMsg.set(13, "1221"); isoMsg.set(14, "1912"); isoMsg.set(15, "1221"); isoMsg.set(18, "6012"); isoMsg.set(22, "020"); isoMsg.set(25, "27"); isoMsg.set(28, "C00000000"); isoMsg.set(30, "C00000000"); isoMsg.set(32, "588892"); isoMsg.set(37, "000540000000"); isoMsg.set(41, "11430000"); isoMsg.set(42, "000000011431143"); isoMsg.set(43, "XYZ Banking"); isoMsg.set(49, "840"); isoMsg.set(56, "1510"); isoMsg.set(59, "0540000000"); isoMsg.set(102, "5000000000000000"); isoMsg.set(123, "100000000000000"); isoMsg.set("127.003", "XYZ XYZ"); isoMsg.set("127.033", "6000"); isoMsg.set(54, "500000000"); byte[] bIsoMsg = isoMsg.pack(); String isoMessage = ""; for (int i = 0; i < bIsoMsg.length; i++) { String a = ""; isoMessage += (char) bIsoMsg[i]; } System.out.println(" Packed ISO8385 Message = '"+isoMessage+"'"); } } Unpacker: import org.jpos.iso.ISOException; import org.jpos.iso.ISOMsg; import org.jpos.iso.ISOUtil; import org.jpos.iso.packager.GenericPackager; import java.io.InputStream; public class UnpackISOMessage { public static void main(String[] args) { UnpackISOMessage iso = new UnpackISOMessage(); try { ISOMsg isoMsg = iso.parseISOMessage(); iso.printISOMessage(isoMsg); } catch (Exception e) { e.printStackTrace(); } } private ISOMsg parseISOMessage() throws Exception { String message = "0200F23E449508E0852000000000040000221650000000000000003170000000000000000115051213594972153630122119121221601202027C00000000C000000000658889200054000000011430000000000011431143XYZ Banking 84000950000000000415100100540000000165000000000000000015100000000000000000060 タ XYZ XYZ 6000"; System.out.printf("Message = %s%n", message); try { InputStream is = getClass().getResourceAsStream("/fields.xml"); GenericPackager packager = new GenericPackager(is); ISOMsg isoMsg = new ISOMsg(); isoMsg.setPackager(packager); isoMsg.unpack(message.getBytes()); return isoMsg; } catch (ISOException e) { throw new Exception(e); } } private void printISOMessage(ISOMsg isoMsg) { try { isoMsg.dump(System.out, ""); System.out.println(ISOUtil.hexdump(isoMsg.pack())); System.out.printf("MTI = %s%n", isoMsg.getMTI()); System.out.println("127.003 : " + isoMsg.getString("127.003")); System.out.println("127.033 : " + isoMsg.getString("127.033")); for (int i = 1; i <= isoMsg.getMaxField(); i++) { if (isoMsg.hasField(i)) { System.out.printf("Field (%s) = %s%n", i, isoMsg.getString(i)); } } } catch (ISOException e) { e.printStackTrace(); } } } fields.xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE isopackager SYSTEM "genericpackager.dtd"> <!--<isofield id="127" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>--> Exception: Message = 0200F23E449508E0852000000000040000221650000000000000003170000000000000000115051213594972153630122119121221601202027C00000000C000000000658889200054000000011430000000000011431143XYZ Banking 84000950000000000415100100540000000165000000000000000015100000000000000000060 タ XYZ XYZ 6000 java.lang.Exception: org.jpos.iso.ISOException: org.jpos.iso.IFA_LLCHAR: Problem unpacking field 11 (java.lang.NegativeArraySizeException) unpacking field=127, consumed=287 at com.melah.UnpackISOMessage.parseISOMessage(UnpackISOMessage.java:32) at com.melah.UnpackISOMessage.main(UnpackISOMessage.java:14) Caused by: org.jpos.iso.ISOException: org.jpos.iso.IFA_LLCHAR: Problem unpacking field 11 (java.lang.NegativeArraySizeException) unpacking field=127, consumed=287 at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:340) at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:468) at com.melah.UnpackISOMessage.parseISOMessage(UnpackISOMessage.java:29) ... 1 more Jpos Maven Dependency: org.jpos jpos 2.1.2 Code can be found on github: https://github.com/melah500/jpos-field-127.003 JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Thanks for all your responses in assisting me to troubleshoot this. I managed to figure out where the issue was. Initially, what was causing the data not to be unpacked was the issue to do with field 127.11. Well, in my scenario i really had no use for the field so i just removed it from my packager. Then to solve the second issue whereby data in field 127.33 was being truncated, i was using the string isoMessage i had generated in PackerTest, so this string contains some binary data, so some data was being lost along the way. I had to just use the message in byte format to avoid any surprises. Alternatively i could have used a hex value from hexdump using IsoUtil. I just updated my code on github, someone might find it useful. Code can be found on github: https://github.com/melah500/jpos-field-127.003 Thanks.

Related questions

0 votes
    Which of these occupy first 0 to 127 in Unicode character set used for characters in Java? (a) ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 28, 2021 in Education by JackTerrance
0 votes
    Which of the following input control represents a date and time (year, month, day, hour, minute, second, fractions of a second ... - datetime B - datetime-local C - date D - month...
asked Dec 1, 2020 in Technology by JackTerrance
0 votes
    I have a field call query_data defined as text in my MySQL database. In my model I defined this ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    What is the problem Here ? I got an error shows ValueError: too many values to unpack This code ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Actually I am checking the excel values whether they are displayed on the web page Mouse hover menu. The menu includes titles and the ... ")); int submenuui = 0; for (int a=1;a...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have a domain that will be accessed by a small, private group of people. So I want to control ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Which of the following can be used to create sub-samples using a maximum dissimilarity approach? (a) minDissim ... and answers pdf, Data Science interview questions for beginners...
asked Oct 28, 2021 in Education by JackTerrance
0 votes
    I have been trying to connect to my prod server from my dev using connect to remote (which gets ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 8, 2022 in Education by JackTerrance
0 votes
    what i want : i have a config file where it contains some urls in .json file stored in asset ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I write the following code to access the page but this is not working for me if (User.Identity. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I write the following code to access the page but this is not working for me if (User.Identity. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
0 votes
    Which of the following input control represents a date consisting of a year and a week number encoded according to ISO 8601 in Web Form 2.0? A - week B - time C - number D - range...
asked Dec 2, 2020 in Technology by JackTerrance
0 votes
    Which of the following input control represents a date consisting of a year and a month encoded according to ISO 8601 in Web ... - datetime B - datetime-local C - date D - month...
asked Dec 1, 2020 in Technology by JackTerrance
...