Field 127 Subfield of subfield

541 views
Skip to first unread message

Chinyenje Kapoma

unread,
Jul 25, 2018, 11:15:52 AM7/25/18
to jPOS Users


Hi,
Im trying to integrate with Postillion and managed to send an 0800 message . However when trying to do a balance enquiry im getting an error. I have checked traces and found that field 127.22 has a subfield called MSDN and so on sample trace below 

[LLLLLVAans 99999 219] 127.022.MSDN
                                   [260979841847]
   [LLLLLVAans 99999 219] 127.022.UssdSessionId
                                   [mtn:260979841847:df377b66-a181-4763-82ff-280619a71285]
   [LLLLLVAans 99999 219] 127.022.SENDER_FULL_NAME
                                   [X XXXXXX]
   [LLLLLVAans 99999 219] 127.022.CustomApplication
                                   [mob-ussd]
   [LLLLLVAans 99999 219] 127.022.CUSTOM_REFERENCE
                                   [a4cd2feb-95b8-435f-8846-867fcad97991]

Please advise how i can implement this in jpos

chhil

unread,
Jul 25, 2018, 10:36:28 PM7/25/18
to jpos-...@googlegroups.com
Please tell us the specific error/ exception you are getting along with the packager you are using. If it's a custom packager please attach it. 
We understand jpos, so non jpos trace logs don't help us in helping you. 

-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: sa...@jpos.org
---
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.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/363c6cee-e0fa-4f02-92a9-8537ece2a0db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chinyenje Kapoma

unread,
Jul 26, 2018, 2:24:36 PM7/26/18
to jPOS Users
Hi,
Im trying to create a subfield of field 127.22. The external Postilion interface is expecting it as 127.22.MSDN
Jpos error..


Exception in thread "main" org.jpos.iso.ISOException: Error reading packager/pst.xml (org.xml.sax.SAXException: For input string: "MSDN"
java.lang.NumberFormatException: For input string: "MSDN")
at org.jpos.iso.packager.GenericPackager.readFile(GenericPackager.java:198)
at org.jpos.iso.packager.GenericPackager.<init>(GenericPackager.java:121)
at my.jpos.app.bal_enq.main(bal_enq.java:27)
Nested:org.xml.sax.SAXException: For input string: "MSDN"
java.lang.NumberFormatException: For input string: "MSDN"
at org.jpos.iso.packager.GenericPackager$GenericContentHandler.startElement(GenericPackager.java:457)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:506)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:766)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:353)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2715)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1137)
at org.jpos.iso.packager.GenericPackager.readFile(GenericPackager.java:195)
at org.jpos.iso.packager.GenericPackager.<init>(GenericPackager.java:121)
at my.jpos.app.bal_enq.main(bal_enq.java:27)
Caused by: java.lang.NumberFormatException: For input string: "MSDN"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.<init>(Integer.java:677)
at org.jpos.iso.packager.GenericPackager$GenericContentHandler.startElement(GenericPackager.java:452)
... 15 more
Java Result: 1



 im not sure how i can use jpos to create a subfield of a subfield
pst.xml

chhil

unread,
Jul 26, 2018, 10:34:49 PM7/26/18
to jPOS Users
Hi,
I suggest using https://github.com/jpos/jPOS/blob/master/jpos/src/dist/cfg/packager/postpack.xml as your packager,
as we know it works. Just be double sure by going through it to make sure.

On glancing through the difference I believe is that your packager has sub fields defined for some fields
that are a composite of a few fixed sub-fields.
Try postpack.xml that and if it works fix your packager. If you are still having problems provide a hex
(jpos)/binary(postilion) data dump of the 0800 message.

-chhil

chhil

unread,
Jul 26, 2018, 10:52:55 PM7/26/18
to jPOS Users
Hi,

Using postpack.xml you would do a isomsg.getString(127.22) to get the structured data. Then use your own POJO to extract the data from it. Structured data is some variation of [length of length][length][ tag ][value], see the postilion spec for its details, and it can contain many such LTV elements and in any order. You have mis-configured your pst.xml by having 
<isofieldpackager id="22" length="99999" name="RESERVED PRIVATE USE2"class="org.jpos.iso.IFA_LLLLLCHAR"packager="org.jpos.iso.packager.ISO87APackager">
<isofield id="MSDN" length="99999" name="MSDN"class="org.jpos.iso.IFA_LLLLLCHAR"/>

</isofieldpackager>
The isofield element needs to be an integer and you have MSDN and hence it fails. Plus the packager has no understanding of the LTV substructures to extract and give you the data associated with it. That's something you would have to do in your code.

You can refer to https://groups.google.com/d/msg/jpos-users/zT7d5fzGEuQ/_f4pnBcZAkYJ to see a sample breakdown of a structured data field 

-chhil 

Alejandro Revilla

unread,
Jul 26, 2018, 11:01:08 PM7/26/18
to jPOS Users
When user an outer package (in this case field 22's isofieldpackager, it's a good idea to use a BINARY packager instead of CHAR, in this case IFA_LLLLLBINARY. Using LLLLLCHAR happens to work but uses a String conversion (that may involve i18n related issues easily).

My 2 858s



To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.

Chinyenje Kapoma

unread,
Jul 27, 2018, 12:04:20 PM7/27/18
to jPOS Users
Hi i tried what you refered and its not working below is my code implementation

String field22_key1 = "14MSDN"; 
         String field22_key2 = "213UssdSessionId";
         String field22_key3 = "216SENDER_FULL_NAME";
         String field22_key4 = "214VasApplication";
         String field22_key5 = "216XSUITE_REFERENCE";
         String field22_value = "210260953104906";
         String field22_value1 = "210260953104906";//"221MSDN";1....9 is 2 then 10....99
         String field22_value2 = "253mtn:260992210258:298a2003-cc04-4d13-8947-a0435a3d9205";
         String field22_value3 = "212Bing Mostert";
         String field22_value4 = "212xmobile-mmsd";
         String field22_value5 = "2368a9a460f-5932-48ed-96f1-0b9a03a7fe98";
         String field22 = field22_key1+field22_value1+field22_key2+field22_value2+field22_key3+field22_value3+field22_key4+field22_value4+field22_key5+field22_value5;
       m.set("127.22",field22);
       channel.send (m);

Hex dump ...
0000(0000) 30 32 30 30 b2 38 04 c1 00 c0 80 00 00 00 00 00 0200.8..........
0016(0010) 14 00 00 22 33 31 30 30 30 30 30 30 30 30 30 30 ..."310000000000 0032(0020) 30 30 30 30 30 30 30 36 31 34 30 37 33 32 30 34 0000000614073204 0048(0030) 30 30 30 30 30 39 30 37 33 32 30 34 30 37 32 35 0000090732040725 0064(0040) 30 30 30 32 37 31 32 30 36 34 30 35 38 32 35 4d 000271206405825M 0080(0050) 42 42 51 30 30 30 31 4d 4f 42 30 30 30 30 30 30 BBQ0001MOB000000 0096(0060) 30 30 30 30 30 31 39 36 37 30 36 31 31 31 31 31 0000019670611111 0112(0070) 31 31 33 31 37 39 37 39 34 35 32 30 30 31 32 36 1131797945200126 0128(0080) 30 31 35 31 30 30 34 35 30 31 30 30 31 33 30 30 0151004501001300 0144(0090) 32 31 30 30 30 32 33 30 00 00 04 00 00 00 00 00 21000230........ 0160(00a0) 30 30 32 31 37 31 34 4d 53 44 4e 32 31 30 32 36 0021714MSDN21026 0176(00b0) 30 39 35 33 31 30 34 39 30 36 32 31 33 55 73 73 0953104906213Uss 0192(00c0) 64 53 65 73 73 69 6f 6e 49 64 32 35 33 6d 74 6e dSessionId253mtn 0208(00d0) 3a 32 36 30 39 36 32 32 31 30 32 35 38 3a 32 39 :260992210258:29 0224(00e0) 38 61 32 30 30 33 2d 63 63 30 34 2d 34 64 31 33 8a2003-cc04-4d13 0240(00f0) 2d 38 39 34 37 2d 61 30 34 33 35 61 33 64 39 32 -8947-a0435a3d92 0256(0100) 30 35 32 31 36 53 45 4e 44 45 52 5f 46 55 4c 4c 05216SENDER_FULL 0272(0110) 5f 4e 41 4d 45 32 31 32 4a 6f 68 6e 20 4d 6f 73 _NAME212Bing Mos 0288(0120) 74 65 72 74 32 31 34 56 61 73 41 70 70 6c 69 63 tert214VasApplic 0304(0130) 61 74 69 6f 6e 32 31 32 76 6d 6f 62 69 6c 65 2d ation212vmobile- 0320(0140) 75 73 73 64 32 31 36 56 53 55 49 54 45 5f 52 45 mssd216XSUITE_RE 0336(0150) 46 45 52 45 4e 43 45 32 33 36 38 61 39 61 34 36 FERENCE2368a9a46 0352(0160) 30 66 2d 35 39 33 32 2d 34 38 65 64 2d 39 36 66 0f-5932-48ed-96f 0368(0170) 31 2d 30 62 39 61 30 33 61 37 66 65 39 38 1-0b9a03a7fe98

chhil

unread,
Jul 28, 2018, 12:29:30 AM7/28/18
to jpos-...@googlegroups.com
What is not working?
Have you asked the Postilion side on what is wrong?
Have you looked at your Postilion spec and constructed your message as required?

You cannot put a snippet of code saying its not working. Currently only you know whats not working.

-chhil

CK

unread,
Jul 28, 2018, 1:39:55 AM7/28/18
to jPOS Users
Hi from postilion side it’s complaining of invalid field length.Its failing to read field 127.22 sub fields

chhil

unread,
Jul 28, 2018, 1:40:37 AM7/28/18
to jpos-...@googlegroups.com
Hi,

        String field22_value = "210260953104906";
        String field22_value1 = "210260953104906";//"221MSDN";1....9 is 2 then 10....99
Length should be 12 and not 10 , so it should be  212260953104906

package sample;

import java.util.HashMap;
import java.util.Map;

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

public class UnpackISOMessagePostPack {

    static int offset;
    public static void unpackStructredData(String f127_22) {

        Map<String, String> structuredDataMap = new HashMap<>();
        while (offset < f127_22.length()) {
            int lengthOfLengthOfTag = Integer.parseInt(getData(f127_22, 1));
            int lengthOfTag = Integer.parseInt(getData(f127_22, lengthOfLengthOfTag));
            String tag = getData(f127_22, lengthOfTag);
            int lengthOfLengthOfValue = Integer.parseInt(getData(f127_22, 1));
            int lengthOfValue = Integer.parseInt(getData(f127_22, lengthOfLengthOfValue));
            String value = getData(f127_22, lengthOfValue);
            System.out.println(tag + ":" + value);
            structuredDataMap.put(tag, value);
        }
        System.out.println(structuredDataMap);

    }

    private static String getData(String f127_22,int size) {

        return f127_22.substring(offset, offset += size);

    }

    public static void main(String[] args) {

        String message = "30 32 30 30 b2 38 04 c1  00 c0 80 00 00 00 00 00"
                + "14 00 00 22 33 31 30 30  30 30 30 30 30 30 30 30"
                + "30 30 30 30 30 30 30 36  31 34 30 37 33 32 30 34"
                + "30 30 30 30 30 39 30 37  33 32 30 34 30 37 32 35"
                + "30 30 30 32 37 31 32 30  36 34 30 35 38 32 35 4d"
                + "42 42 51 30 30 30 31 4d  4f 42 30 30 30 30 30 30"
                + "30 30 30 30 30 31 39 36  37 30 36 31 31 31 31 31"
                + "31 31 33 31 37 39 37 39  34 35 32 30 30 31 32 36" // changed
                                                                     // 30 to 32
                                                                     // in th
                                                                     // second
                                                                     // last
                                                                     // position
                                                                     // as the
                                                                     // length
                                                                     // of data
                                                                     // is 12
                                                                     // and not
                                                                     // 10
                + "30 31 35 31 30 30 34 35  30 31 30 30 31 33 30 30"
                + "32 31 30 30 30 32 33 30  00 00 04 00 00 00 00 00"
                + "30 30 32 31 37 31 34 4d  53 44 4e 32 31 32 32 36"
                + "30 39 35 33 31 30 34 39  30 36 32 31 33 55 73 73"
                + "64 53 65 73 73 69 6f 6e  49 64 32 35 33 6d 74 6e"
                + "3a 32 36 30 39 36 32 32  31 30 32 35 38 3a 32 39"
                + "38 61 32 30 30 33 2d 63  63 30 34 2d 34 64 31 33"
                + "2d 38 39 34 37 2d 61 30  34 33 35 61 33 64 39 32"
                + "30 35 32 31 36 53 45 4e  44 45 52 5f 46 55 4c 4c"
                + "5f 4e 41 4d 45 32 31 32  4a 6f 68 6e 20 4d 6f 73"
                + "74 65 72 74 32 31 34 56  61 73 41 70 70 6c 69 63"
                + "61 74 69 6f 6e 32 31 32  76 6d 6f 62 69 6c 65 2d"
                + "75 73 73 64 32 31 36 56  53 55 49 54 45 5f 52 45"
                + "46 45 52 45 4e 43 45 32  33 36 38 61 39 61 34 36"
                + "30 66 2d 35 39 33 32 2d  34 38 65 64 2d 39 36 66"
                + "31 2d 30 62 39 61 30 33  61 37 66 65 39 38      ";
        message = message.replaceAll(" ", "");

        Logger l = new Logger();
        l.addListener(new SimpleLogListener());
        ISOMsg m = new ISOMsg();
        GenericPackager p;
        try {
            p = new GenericPackager("path to postpack.xml");
            m.setPackager(p);
            m.unpack(ISOUtil.hex2byte(message)); // You need to convert the hex
                                                 // string to bytes
            m.dump(System.out, "");
            System.out.println(ISOUtil.hexdump(m.pack()));

            UnpackISOMessagePostPack.unpackStructredData(m.getString("127.22"));
        }
        catch (ISOException e) {

            e.printStackTrace();
            m.dump(System.out, "");
        }

    }

}

Output 

<isomsg>
  <!-- org.jpos.iso.packager.GenericPackager[C:\SourceRepo\OII\Incomm\build\cfg\postpack.xml] -->
  <field id="0" value="0200"/>
  <field id="3" value="310000"/>
  <field id="4" value="000000000000"/>
  <field id="7" value="0614073204"/>
  <field id="11" value="000009"/>
  <field id="12" value="073204"/>
  <field id="13" value="0725"/>
  <field id="22" value="000"/>
  <field id="25" value="27"/>
  <field id="26" value="12"/>
  <field id="32" value="405825"/>
  <field id="41" value="MBBQ0001"/>
  <field id="42" value="MOB000000000001"/>
  <field id="49" value="967"/>
  <field id="100" value="111111"/>
  <field id="102" value="1797945200126"/>
  <field id="123" value="100450100130021"/>
  <isomsg id="127">
    <!-- org.jpos.iso.packager.GenericSubFieldPackager -->
    <field id="22" value="14MSDN212260953104906213UssdSessionId253mtn:260962210258:298a2003-cc04-4d13-8947-a0435a3d9205216SENDER_FULL_NAME212John Mostert214VasApplication212vmobile-ussd216VSUITE_REFERENCE2368a9a460f-5932-48ed-96f1-0b9a03a7fe98"/>
  </isomsg>
</isomsg>
0000  30 32 30 30 B2 38 04 C1  00 C0 80 00 00 00 00 00  0200.8..........
0010  14 00 00 22 33 31 30 30  30 30 30 30 30 30 30 30  ..."310000000000
0020  30 30 30 30 30 30 30 36  31 34 30 37 33 32 30 34  0000000614073204
0030  30 30 30 30 30 39 30 37  33 32 30 34 30 37 32 35  0000090732040725
0040  30 30 30 32 37 31 32 30  36 34 30 35 38 32 35 4D  000271206405825M
0050  42 42 51 30 30 30 31 4D  4F 42 30 30 30 30 30 30  BBQ0001MOB000000
0060  30 30 30 30 30 31 39 36  37 30 36 31 31 31 31 31  0000019670611111
0070  31 31 33 31 37 39 37 39  34 35 32 30 30 31 32 36  1131797945200126
0080  30 31 35 31 30 30 34 35  30 31 30 30 31 33 30 30  0151004501001300
0090  32 31 30 30 30 32 33 30  00 00 04 00 00 00 00 00  21000230........
00a0  30 30 32 31 37 31 34 4D  53 44 4E 32 31 32 32 36  0021714MSDN21226
00b0  30 39 35 33 31 30 34 39  30 36 32 31 33 55 73 73  0953104906213Uss
00c0  64 53 65 73 73 69 6F 6E  49 64 32 35 33 6D 74 6E  dSessionId253mtn
00d0  3A 32 36 30 39 36 32 32  31 30 32 35 38 3A 32 39  :260962210258:29
00e0  38 61 32 30 30 33 2D 63  63 30 34 2D 34 64 31 33  8a2003-cc04-4d13
00f0  2D 38 39 34 37 2D 61 30  34 33 35 61 33 64 39 32  -8947-a0435a3d92
0100  30 35 32 31 36 53 45 4E  44 45 52 5F 46 55 4C 4C  05216SENDER_FULL
0110  5F 4E 41 4D 45 32 31 32  4A 6F 68 6E 20 4D 6F 73  _NAME212John Mos
0120  74 65 72 74 32 31 34 56  61 73 41 70 70 6C 69 63  tert214VasApplic
0130  61 74 69 6F 6E 32 31 32  76 6D 6F 62 69 6C 65 2D  ation212vmobile-
0140  75 73 73 64 32 31 36 56  53 55 49 54 45 5F 52 45  ussd216VSUITE_RE
0150  46 45 52 45 4E 43 45 32  33 36 38 61 39 61 34 36  FERENCE2368a9a46
0160  30 66 2D 35 39 33 32 2D  34 38 65 64 2D 39 36 66  0f-5932-48ed-96f
0170  31 2D 30 62 39 61 30 33  61 37 66 65 39 38        1-0b9a03a7fe98

MSDN:260953104906
UssdSessionId:mtn:260962210258:298a2003-cc04-4d13-8947-a0435a3d9205
SENDER_FULL_NAME:John Mostert
VasApplication:vmobile-ussd
VSUITE_REFERENCE:8a9a460f-5932-48ed-96f1-0b9a03a7fe98
{MSDN=260953104906, UssdSessionId=mtn:260962210258:298a2003-cc04-4d13-8947-a0435a3d9205, SENDER_FULL_NAME=John Mostert, VSUITE_REFERENCE=8a9a460f-5932-48ed-96f1-0b9a03a7fe98, VasApplication=vmobile-ussd}

-chhil


CK

unread,
Jul 28, 2018, 2:40:20 AM7/28/18
to jPOS Users
Hi,
Thanks for your suggestions and pointing me to the right path. The implementation worked it was just a problem with the field length definitions. Im now able to pack the message correctly and postillion able to read it .
Reply all
Reply to author
Forward
0 new messages