[jpos-users] ISoMessage unpacking Exception

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[jpos-users] ISoMessage unpacking Exception

Abdullah Al Noman Opu

I just want to parse an ISO message using Jpose, For that, I wrote some code like  as follows.... and having an exception like

 Exception in thread "main" org.jpos.iso.ISOException: org.jpos.iso.IF_CHAR: Problem unpacking field 41 (java.lang.StringIndexOutOfBoundsException: String index out of range: 120) unpacking field=41, consumed=112


bellow is my code and xml file . Can someone tell me Why I am facing this exception and what can I do to solve this !!!!! 


public static void main(String[] args) throws IOException, ISOException {
// Create Packager based on XML that contain DE type
GenericPackager packager = new GenericPackager("/src/main/resources/field.xml");

// Print Input Data
String data = "0410723A40010E808000164445167778029910000000000000011300012609410310058515403701260126581400100000000585 0910000001050";
System.out.println("DATA : " + data);

// Create ISO Message
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.unpack(data.getBytes());

// print the DE list
logISOMsg(isoMsg);
}

private static void logISOMsg(ISOMsg msg) {
System.out.println("----ISO MESSAGE-----");
try {
System.out.println(" MTI : " + msg.getMTI());
for (int i=1;i<=msg.getMaxField();i++) {
if (msg.hasField(i)) {
System.out.println(" Field-"+i+" : "+msg.getString(i));
}
}
} catch (ISOException e) {
e.printStackTrace();
} finally {
System.out.println("--------------------");
}

}

and XML file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager SYSTEM "genericpackager.dtd"><isopackager>
<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="19" name="SECRET ID" 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"/>
<isofield id="5" length="12" name="AMOUNT, SETTLEMENT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="6" length="12" name="AMOUNT, CARDHOLDER BILLING" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="7" length="10" name="TRANSMISSION DATE AND TIME" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="8" length="8" name="AMOUNT, CARDHOLDER BILLING FEE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="9" length="8" name="CONVERSION RATE, SETTLEMENT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="10" length="8" name="CONVERSION RATE, CARDHOLDER BILLING" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="11" length="6" name="SYSTEM TRACE AUDIT NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="12" length="6" name="TIME, LOCAL TRANSACTION" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="13" length="4" name="DATE, LOCAL TRANSACTION" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="14" length="4" name="DATE, EXPIRATION" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="15" length="4" name="DATE, SETTLEMENT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="16" length="4" name="DATE, CONVERSION" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="17" length="4" name="DATE, CAPTURE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="18" length="4" name="MERCHANTS TYPE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="19" length="3" name="ACQUIRING INSTITUTION COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="20" length="3" name="PAN EXTENDED COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="21" length="3" name="FORWARDING INSTITUTION COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="22" length="3" name="POINT OF SERVICE ENTRY MODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="23" length="3" name="CARD SEQUENCE NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="24" length="3" name="NETWORK INTERNATIONAL IDENTIFIEER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="25" length="2" name="POINT OF SERVICE CONDITION CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="26" length="2" name="POINT OF SERVICE PIN CAPTURE CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="27" length="1" name="AUTHORIZATION IDENTIFICATION RESP LEN" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="28" length="9" name="AMOUNT, TRANSACTION FEE" class="org.jpos.iso.IFA_AMOUNT"/>
<isofield id="29" length="9" name="AMOUNT, SETTLEMENT FEE" class="org.jpos.iso.IFA_AMOUNT"/>
<isofield id="30" length="9" name="AMOUNT, TRANSACTION PROCESSING FEE" class="org.jpos.iso.IFA_AMOUNT"/>
<isofield id="31" length="9" name="AMOUNT, SETTLEMENT PROCESSING FEE" class="org.jpos.iso.IFA_AMOUNT"/>
<isofield id="32" length="11" name="ACQUIRING INSTITUTION IDENT CODE" class="org.jpos.iso.IFA_LLNUM"/>
<isofield id="33" length="11" name="FORWARDING INSTITUTION IDENT CODE" class="org.jpos.iso.IFA_LLNUM"/>
<isofield id="34" length="28" name="PAN EXTENDED" class="org.jpos.iso.IFA_LLCHAR"/>
<isofield id="35" length="37" name="TRACK 2 DATA" class="org.jpos.iso.IFA_LLNUM"/>
<isofield id="36" length="104" name="TRACK 3 DATA" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="37" length="12" name="RETRIEVAL REFERENCE NUMBER" class="org.jpos.iso.IF_CHAR"/>
<isofield id="38" length="6" name="AUTHORIZATION IDENTIFICATION RESPONSE" class="org.jpos.iso.IF_CHAR"/>
<isofield id="39" length="2" name="RESPONSE CODE" class="org.jpos.iso.IF_CHAR"/>
<isofield id="40" length="3" name="SERVICE RESTRICTION CODE" class="org.jpos.iso.IF_CHAR"/>
<isofield id="41" length="8" name="CARD ACCEPTOR TERMINAL IDENTIFICACION" class="org.jpos.iso.IF_CHAR"/>
<isofield id="42" length="15" name="CARD ACCEPTOR IDENTIFICATION CODE" class="org.jpos.iso.IF_CHAR"/>
<isofield id="43" length="40" name="CARD ACCEPTOR NAME/LOCATION" class="org.jpos.iso.IF_CHAR"/>
<isofield id="44" length="25" name="ADITIONAL RESPONSE DATA" class="org.jpos.iso.IFA_LLCHAR"/>
<isofield id="45" length="76" name="TRACK 1 DATA" class="org.jpos.iso.IFA_LLCHAR"/>
<isofield id="46" length="999" name="ADITIONAL DATA - ISO" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="47" length="999" name="ADITIONAL DATA - NATIONAL" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="48" length="999" name="ADITIONAL DATA - PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="49" length="3" name="CURRENCY CODE, TRANSACTION" class="org.jpos.iso.IF_CHAR"/>
<isofield id="50" length="3" name="CURRENCY CODE, SETTLEMENT" class="org.jpos.iso.IF_CHAR"/>
<isofield id="51" length="3" name="CURRENCY CODE, CARDHOLDER BILLING" class="org.jpos.iso.IF_CHAR"/>
<isofield id="52" length="16" name="PIN DATA" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="53" length="16" name="SECURITY RELATED CONTROL INFORMATION" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="54" length="120" name="ADDITIONAL AMOUNTS" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="55" length="999" name="RESERVED ISO" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="56" length="999" name="RESERVED ISO" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="57" length="999" name="RESERVED NATIONAL" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="58" length="999" name="RESERVED NATIONAL" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="59" length="999" name="RESERVED NATIONAL" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="60" length="999" name="RESERVED PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="61" length="999" name="RESERVED PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="62" length="999" name="RESERVED PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="63" length="999" name="RESERVED PRIVATE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="64" length="8" name="MESSAGE AUTHENTICATION CODE FIELD" class="org.jpos.iso.IFA_BINARY"/>
<isofield id="65" length="1" name="BITMAP, EXTENDED" class="org.jpos.iso.IFA_BINARY"/>
<isofield id="66" length="1" name="SETTLEMENT CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="67" length="2" name="EXTENDED PAYMENT CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="68" length="3" name="RECEIVING INSTITUTION COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="69" length="3" name="SETTLEMENT INSTITUTION COUNTRY CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="70" length="3" name="NETWORK MANAGEMENT INFORMATION CODE" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="71" length="4" name="MESSAGE NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="72" length="4" name="MESSAGE NUMBER LAST" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="73" length="6" name="DATE ACTION" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="74" length="10" name="CREDITS NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="75" length="10" name="CREDITS REVERSAL NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="76" length="10" name="DEBITS NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="77" length="10" name="DEBITS REVERSAL NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="78" length="10" name="TRANSFER NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="79" length="10" name="TRANSFER REVERSAL NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="80" length="10" name="INQUIRIES NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="81" length="10" name="AUTHORIZATION NUMBER" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="82" length="12" name="CREDITS, PROCESSING FEE AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="83" length="12" name="CREDITS, TRANSACTION FEE AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="84" length="12" name="DEBITS, PROCESSING FEE AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="85" length="12" name="DEBITS, TRANSACTION FEE AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="86" length="16" name="CREDITS, AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="87" length="16" name="CREDITS, REVERSAL AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="88" length="16" name="DEBITS, AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="89" length="16" name="DEBITS, REVERSAL AMOUNT" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="90" length="42" name="ORIGINAL DATA ELEMENTS" class="org.jpos.iso.IFA_NUMERIC"/>
<isofield id="91" length="1" name="FILE UPDATE CODE" class="org.jpos.iso.IF_CHAR"/>
<isofield id="92" length="2" name="FILE SECURITY CODE" class="org.jpos.iso.IF_CHAR"/>
<isofield id="93" length="6" name="RESPONSE INDICATOR" class="org.jpos.iso.IF_CHAR"/>
<isofield id="94" length="7" name="SERVICE INDICATOR" class="org.jpos.iso.IF_CHAR"/>
<isofield id="95" length="42" name="REPLACEMENT AMOUNTS" class="org.jpos.iso.IF_CHAR"/>
<isofield id="96" length="16" name="MESSAGE SECURITY CODE" class="org.jpos.iso.IFA_BINARY"/>
<isofield id="97" length="17" name="AMOUNT, NET SETTLEMENT" class="org.jpos.iso.IFA_AMOUNT"/>
<isofield id="98" length="25" name="PAYEE" class="org.jpos.iso.IF_CHAR"/>
<isofield id="99" length="11" name="SETTLEMENT INSTITUTION IDENT CODE" class="org.jpos.iso.IFA_LLNUM"/>
<isofield id="100" length="11" name="RECEIVING INSTITUTION IDENT CODE" class="org.jpos.iso.IFA_LLNUM"/>
<isofield id="101" length="17" name="FILE NAME" class="org.jpos.iso.IFA_LLCHAR"/>
<isofield id="102" length="28" name="FROM ACCOUNT" class="org.jpos.iso.IFA_LLCHAR"/>
<isofield id="103" length="10" name="ACCOUNT IDENTIFICATION 2" class="org.jpos.iso.IFA_LLCHAR"/>
<isofield id="104" length="100" name="TRANSACTION DESCRIPTION" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="105" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="106" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="107" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="108" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="109" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="110" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="111" length="999" name="RESERVED ISO USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="112" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="113" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="114" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="115" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="116" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="117" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="118" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="119" length="999" name="RESERVED NATIONAL USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="120" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="121" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="122" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="123" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="124" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="125" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="126" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="127" length="999" name="RESERVED PRIVATE USE" class="org.jpos.iso.IFA_LLLCHAR"/>
<isofield id="128" length="8" name="MAC 2" class="org.jpos.iso.IFA_BINARY"/>
</isopackager>

--
--
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: [hidden email]
---
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/a3999d8a-81da-4130-8e8e-74a4d93c91f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [jpos-users] ISoMessage unpacking Exception

chhil
​Please go through your specification and make sure your field packagers match the spec.

Check your output to make sure the field contents are correct and if they are not check your spec and packager definition​n

Next time search the group, these sort of queries are answered too many times already providing the same instruction.​

​```
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.packager.GenericPackager;
import org.jpos.util.Logger;
import org.jpos.util.SimpleLogListener;

public class Test {



    public static void main(String[] args) {
        Logger l = new Logger();
        l.addListener(new SimpleLogListener());
        String data= "0410723A40010E808000164445167778029910000000000000011300012609410310058515403701260126581400100000000585 ";
        ISOMsg m = new ISOMsg();
        GenericPackager p;
        try {
            p = new GenericPackager("cfg\\File.xml");
            p.setLogger(l, "");
            m.setPackager(p);
            m.unpack(data.getBytes());
        }
        catch (ISOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            m.dump(System.out, "!");
        }

    }
}
```

output

!<isomsg direction="none">
!  <!-- org.jpos.iso.packager.GenericPackager[C:\SourceRepo\OII\Incomm\build\cfg\File.xml] -->
!  <field id="0" value="0410"/>
!  <field id="bitmap" value="{2, 3, 4, 7, 11, 12, 13, 15, 18, 32, 37, 38, 39, 41, 49}" type="bitmap"/>
!  <field id="2" value="4445167778029910"/>
!  <field id="3" value="000000"/>
!  <field id="4" value="000000011300"/>
!  <field id="7" value="0126094103"/>
!  <field id="11" value="100585"/>
!  <field id="12" value="154037"/>
!  <field id="13" value="0126"/>
!  <field id="15" value="0126"/>
!  <field id="18" value="5814"/>
!  <field id="32" value=""/>
!  <field id="37" value="100000000585"/>
!</isomsg>

​-chhil​

--
--
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: [hidden email]
---
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAPazefDg62vkYGMx6YiZvbFmSvyXLVhi7_ZVYtYhjGsowCzCWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...