Error unpacking termapp.iso response

172 views
Skip to first unread message

flavian machimbirike

unread,
Oct 28, 2023, 1:16:15 PM10/28/23
to jpos-...@googlegroups.com
Dear Team,

I trust you are in good health. I'm encountering an issue while sending a message labeled "1304" to a Termapp.iso server. The request and response are correctly logged in Postilion. However, my application is failing to properly unpack the response, resulting in garbled data. Upon closer examination, I discovered that the response I receive contains header information from the request, which prevents me from unpacking it successfully.

Here are my questions:

1. Is there a way for me to obtain the unpacked string so that I can extract the header and then use my custom packager to unpack the message?
2. Do I need to make any modifications to my packager to ensure that the header is not included in the response?
3. How do I properly unpack the message 

I would greatly appreciate any assistance.

Attached, please find my packager and the code snippet:

public String test() throws Exception {
    // this.unpack("313330348030010000C000000200000008000000303030303031303030303030323331303233333035504F534330303031504F534330303030303030303030313030303030303030313541423A303030303A6170705F6D6170");
    ISOMsg isoMsg = new ISOMsg("1304");
    isoMsg.setDirection(OUTGOING);
    isoMsg.setHeader(ISOUtil.hex2byte("00"));
    isoMsg.set("011", "000001");
    isoMsg.set("012", "231023");
    isoMsg.set("024", "305");
    isoMsg.set("041", "POSC0001");
    isoMsg.set("042", "POSC00000000001");
    isoMsg.set("071", "0000");
    isoMsg.set("101", ISOUtil.hex2byte("41423A303030303A6170705F6D6170"));
    sendRequest(isoMsg);
    return "To infinity and beyond";
}

private ISOMsg sendRequest(ISOMsg isoMsg) throws Exception {
    log.info("########################### Sending Messages: {}");
    try {
        Logger logger = new Logger();
        logger.addListener(new SimpleLogListener(System.out));
        // ISOChannel channel = new PostChannel("######", 9305, packager);

        ((LogSource) channel).setLogger(logger, "xml-server-9000");
        channel.connect();
        channel.send(isoMsg);

        return channel.receive();
    } catch (IOException | ISOException ex) {
        if (ex instanceof SocketException) {
            log.info("########################### Issuer unavailable: {}", ex.getMessage());
        }
        log.info("########################### Failing to connect: {}", ex.getMessage());
        throw new IOException("Failed to connect");
    }
}

public String unpack(String string) {
    String isoMessage = string;
    try {
        // Create a GenericPackager using the appropriate XML configuration file
        ISOPackager packager = new GenericPackager("C:\\Users\\ALTRON-FLA\\Documents\\N\\hsm-client\\src\\main\\resources\\isoswitch.xml"); // Replace with the path to your ISO message structure configuration file

        // Create an ISOMsg instance
        ISOMsg isoMsg = new ISOMsg();
        // Unpack the ISO message
        isoMsg.setPackager(packager);
        isoMsg.unpack(ISOUtil.hex2byte(isoMessage));
        // Access and print individual ISO fields
        for (int i = 2; i <= 128; i++) {
            if (isoMsg.hasField(i)) {
                System.out.println("Field " + i + ": " + isoMsg.getString(i));
            }
        }
    } catch (ISOException e) {
        e.printStackTrace();
    }

    return null;
}


Request: 
 <pack>
    313330348030010000C000000200000008000000303030303031303030303030323331303233333035504F534330303031504F534330303030303030303030313030303030303030313541423A303030303A6170705F6D6170
  </pack>
<isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.GenericPackager[C:\Users\ALTRON-FLA\Documents\N\hsm-client\isoswitch.xml] -->
      <header>00</header>
      <field id="0" value="1304"/>
      <field id="11" value="000001"/>
      <field id="12" value="231023"/>
      <field id="24" value="305"/>
      <field id="41" value="POSC0001"/>
      <field id="42" value="POSC00000000001"/>
      <field id="71" value="0000"/>
      <field id="101" value="41423A303030303A6170705F6D6170" type="binary"/>
    </isomsg>


Response throwing exceptions: 
<unpack>
 00313331348020010002C000000300000008000000303030303031333036333030504F534330303031504F534330303030303030303030313030303030303031303434412C30303030303433342E432C30303030303030392E442C30303030303031462E452C30303030303043302E313541423A303030303A6170705F6D6170

Bitmap 
0000  00 31 33 31 34 80 20 01  00 02 C0 00 00 03 00 00  .1314. .........
0010  00 08 00 00 00 30 30 30  30 30 31 33 30 36 33 30  .....00000130630
0020  30 50 4F 53 43 30 30 30  31 50 4F 53 43 30 30 30  0POSC0001POSC000
0030  30 30 30 30 30 30 30 31  30 30 30 30 30 30 30 31  0000000100000001
0040  30 34 34 41 2C 30 30 30  30 30 34 33 34 2E 43 2C  044A,00000434.C,
0050  30 30 30 30 30 30 30 39  2E 44 2C 30 30 30 30 30  00000009.D,00000
0060  30 31 46 2E 45 2C 30 30  30 30 30 30 43 30 2E 31  01F.E,000000C0.1
0070  35 41 42 3A 30 30 30 30  3A 61 70 70 5F 6D 61 70  5AB:0000:app_map


Best regards,

Flavian T Machimbirike 
+263719288500 (Whatsapp)
POSC0001_1.html
isoswitch.xml

Mapfunde Venon

unread,
Oct 28, 2023, 1:38:28 PM10/28/23
to jpos-...@googlegroups.com
@SpringBootApplication
public class Demo4JposTermappApplication implements CommandLineRunner {

public static void main(String[] args) {
SpringApplication.run(Demo4JposTermappApplication.class, args);
}

@Override
public void run(String... args) throws Exception {
String rawMessage = """
313331348020010002C000000300000008000000303030303031333036333030504F534330303031504F534330303030303030303030313030303030303031303434412C30303030303433342E432C30303030303030392E442C30303030303031462E452C30303030303043302E313541423A303030303A6170705F6D6170
""";
testConnection(rawMessage);
}

public void testConnection(String message) {

ISOMsg m = new ISOMsg();
try {
GenericPackager pkg = new GenericPackager("file:packager/isoswitch.xml");

Logger l = new Logger();
l.addListener(new SimpleLogListener());
pkg.setLogger(l, "");
m.setPackager(pkg);

byte[] arr = ISOUtil.hex2byte(message.replace(" ", "").trim());
m.unpack(arr);
m.dump(System.out, "");



} catch (Exception e) {
e.printStackTrace();
}
}
}

The first two 0s represent the header.

Venon Mapfunde(PMP,Msc Software Engineering,Bsc Computer Science & Mathematics) Tel:+263 775 091 262 Email:taka...@gmail.com Skype: venon.mapfunde


--
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CACSnBajs%2B%2BVUcyWMksseu5gQPn-_m_m-yu378qGXOJedz1yHAg%40mail.gmail.com.

Mark Salter

unread,
Oct 29, 2023, 5:03:27 AM10/29/23
to jpos-...@googlegroups.com
You ate putting a header on your request, so I figure this interface needs one? Please confirm.

If that is right, then each direction will need the same, otherwise check the documentation of whatever is responding to make sure.

I think PostChannel may need a hint of the expected header size for the receive, but try to male sure right now. Try a call to setHeader on PostChannel passing a hex string of the expected header sizes you create the channel instance, then try the exchange again


-- 
Mark


Sent from Proton Mail mobile



-------- Original Message --------
--
signature.asc

cap10mycap10

unread,
Oct 30, 2023, 8:08:38 PM10/30/23
to jPOS Users

@Mark you are right, this is what you need to do on the channel:

private ISOMsg sendRequest(ISOMsg isoMsg) throws Exception {
log.info("########################### Sending Messages: {}");
try {
Logger logger = new Logger();
logger.addListener(new SimpleLogListener(System.out));

ISOChannel channel = new NACChannel("x.x.x.", yyyy, packager, ISOUtil.hex2byte("0"));

((LogSource) channel).setLogger(logger, "xml-server-9000");
channel.connect();
channel.send(isoMsg);
ISOMsg response = channel.receive();
return response;
} catch (IOException | ISOException ex) {

if (ex instanceof SocketException) {
log.info("########################### Issuer unavailable: {}", ex.getMessage());
}
log.info("########################### Failing to connect: {}", ex.getMessage());
throw new IOException("Failed to connect");
}
}

I should also point out this way of sending request is just to demonstrate how Jpos works, for production purposes you have to consider something else.

flavian machimbirike

unread,
Oct 31, 2023, 2:00:43 AM10/31/23
to jpos-...@googlegroups.com, Mapfunde Venon
Thank you @Mapfunde Venon  I managed to get the 1304 message to work with the above code. 

Kind regards 

Flavian

flavian machimbirike

unread,
Nov 6, 2023, 1:36:06 PM11/6/23
to jPOS Users
Hi Team

I am currently facing an issue with Field 48 where it is throwing the following error on my sale request (1200) from the point of sale terminal:
 <iso-exception>
      error packing field 48
 </iso-exception>

 Below is my packager NB: Field 48 has sub fields.

<?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.IFB_BITMAP"/>
    <isofield
            id="2"
            length="19"
            name="PAN - PRIMARY ACCOUNT NUMBER"
            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, Reconciliation"
            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, Reconciliation"
            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="12"
            name="DATE TIME, LOCAL TRANSACTION YYMMDDhhmmss"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="13"
            length="4"
            name="Date, Effective"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="14"
            length="4"
            name="DATE, EXPIRATION YYMM"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="15"
            length="6"
            name="DATE, SETTLEMENT YYMMDD"
            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="Merchant 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="Country code, Primary account number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="21"
            length="3"
            name="Country code, Forwarding institution"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="22"
            length="12"
            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="4"
            name="Message reason code"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="26"
            length="4"
            name="Card Acceptor Business Code"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="27"
            length="1"
            name="Approval code length"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="28"
            length="6"
            name="Date, Reconciliation"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="29"
            length="3"
            name="Reconciliation indicator"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="30"
            length="24"
            name="Amounts, original"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="31"
            length="99"
            name="Acquirer reference data"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <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="Primary account number, extended"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield
            id="35"
            length="37" name="TRACK 2 DATA"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <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="Approval code"
            class="org.jpos.iso.IF_CHAR"/>
    <isofield
            id="39"
            length="3"
            name="RESPONSE CODE"
            class="org.jpos.iso.IF_CHAR"/>
    <isofield
            id="40"
            length="3"
            name="Service code"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <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.IFA_LLCHAR"/>
    <isofield
            id="44"
            length="99"
            name="Additional 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="204"
            name="Amounts, Fees"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="47"
            length="999"
            name="Additional data - national"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofieldpackager
            id="48"
            length="999"
            name="Additional data - private"
            class="org.jpos.iso.IFA_LLLCHAR"
            packager="org.jpos.iso.packager.GenericSubFieldPackager">
        <isofield
                id="1"
                length="19"
                name="POS DATA"
                class="org.jpos.iso.IF_CHAR"/>

        <isofield
                id="16"
                length="9999"
                name="Structured Data"
                class="org.jpos.iso.IFA_LLLLCHAR"/>
    </isofieldpackager>

    <isofield
            id="49"
            length="3"
            name="CURRENCY CODE, TRANSACTION"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="50"
            length="3"
            name="Currency code, Reconciliation"
            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="8"
            name="PIN DATA"
            class="org.jpos.iso.IFB_BINARY"/>
    <isofield
            id="53"
            length="48"
            name="Security related control information"
            class="org.jpos.iso.IFA_LLBINARY"/>
    <isofield
            id="54"
            length="120"
            name="ADDITIONAL AMOUNTS"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="55"
            length="999"
            name="ICC Data"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="56"
            length="35"
            name="Original Data Elements"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield
            id="57"
            length="3"
            name="Authorization life cycle code"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="58"
            length="11"
            name="Authorizing agent institution Id Code"
            class="org.jpos.iso.IFA_LLNUM"/>
    <isofield
            id="59"
            length="999"
            name=" Transport Data"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="60"
            length="999"
            name="Point of Service Device Type"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="61"
            length="999"
            name="Reserved for national use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="62"
            length="999"
            name="Reserved for private use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="63"
            length="999"
            name="Reserved for private use"
            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="8"
            name="Reserved for ISO use"
            class="org.jpos.iso.IFA_BINARY"/>
    <isofield
            id="66"
            length="204"
            name="Amounts, original fees"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="67"
            length="2"
            name="Extended payment data"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="68"
            length="3"
            name="Country code, receiving institution"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="69"
            length="3"
            name="Country code, settlement institution"
            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="8"
            name="Message number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="72"
            length="999"
            name="Data record"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <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="Authorizations, number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="82"
            length="10"
            name="Inquiries, reversal number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="83"
            length="10"
            name="Payments, number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="84"
            length="10"
            name="Payments, reversal number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="85"
            length="10"
            name="Fee collections, number"
            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="10"
            name="Authorizations, reversal number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="91"
            length="3"
            name="Country code, transaction Dest. Inst."
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="92"
            length="3"
            name="Country code, transaction Orig. Inst."
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="93"
            length="11"
            name="Transaction Destination Institution ID Code"
            class="org.jpos.iso.IFA_LLNUM"/>
    <isofield
            id="94"
            length="11"
            name="Transaction Originator Institution ID Code"
            class="org.jpos.iso.IFA_LLNUM"/>
    <isofield
            id="95"
            length="99"
            name="Card issuer reference data"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield
            id="96"
            length="999"
            name="Key management data"
            class="org.jpos.iso.IFA_LLLBINARY"/>
    <isofield
            id="97"
            length="17"
            name="Amount, Net reconciliation"
            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 Id code"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield
            id="100"
            length="11"
            name="Receiving Institution ID 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="ACCOUNT IDENTIFICATION 1"
            class="org.jpos.iso.IFA_LLNUM"/>
    <isofield
            id="103"
            length="28"
            name="ACCOUNT IDENTIFICATION 2"
            class="org.jpos.iso.IFA_LLNUM"/>
    <isofield
            id="104"
            length="100"
            name="Transaction description"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="105"
            length="16"
            name="Credits, Chargeback amount"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="106"
            length="16"
            name="Debits, Chargeback amount"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="107"
            length="10"
            name="Credits, Chargeback number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="108"
            length="10"
            name="Debits, Chargeback number"
            class="org.jpos.iso.IFA_NUMERIC"/>
    <isofield
            id="109"
            length="84"
            name="Credits, Fee amounts"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield
            id="110"
            length="84"
            name="Debits, Fee amounts"
            class="org.jpos.iso.IFA_LLCHAR"/>
    <isofield
            id="111"
            length="999"
            name="Reserved for ISO use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="112"
            length="999"
            name="Reserved for ISO use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="113"
            length="999"
            name="Reserved for ISO use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="114"
            length="999"
            name="Reserved for ISO use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="115"
            length="999"
            name="Reserved for ISO use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="116"
            length="999"
            name="Reserved for national use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="117"
            length="999"
            name="Reserved for national use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="118"
            length="999"
            name="Reserved for national use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="119"
            length="999"
            name="Reserved for national use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="120"
            length="999"
            name="Reserved for national use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="121"
            length="999"
            name="Reserved for national use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="122"
            length="999"
            name="Reserved for national use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="123"
            length="999"
            name="Reserved for private use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="124"
            length="999"
            name="Reserved for private use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="125"
            length="999"
            name="Reserved for private use"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="126"
            length="999"
            name="Reserved for private use"
            class="org.jpos.iso.IFA_LLLCHAR"/>

    <isofield
            id="127"
            length="99999"
            name="RESERVED PRIVATE USE"
            class="org.jpos.iso.IFA_LLLLLCHAR">
    </isofield>

    <isofield
            id="128"
            length="8"
            name="Message authentication code field"
            class="org.jpos.iso.IFB_BINARY"/>
</isopackager>



Below is my sale request:
 public ISOMsg saleTransaction() throws Exception {
        final ISOMsg isoMsg = new ISOMsg("1200");
        isoMsg.setDirection(OUTGOING);
        isoMsg.set(3, "000000");
        isoMsg.set(4, "000000000280");
        isoMsg.set(7, "1106022517");
        isoMsg.set(11, "000013");
        isoMsg.set(12, "231106102517");
        isoMsg.set(22, "A10101513346");
        isoMsg.set(23, "001");
        isoMsg.set(24, "200");
        isoMsg.set(29, "001");
        isoMsg.set(35, "6079953000000474D33122260786909001");
        isoMsg.set(41, "APOS0001");
        isoMsg.set(42, "300041310020157");
        isoMsg.set(49, "932");
        isoMsg.set("48.001", "APOS0001000013");
        isoMsg.set("48.016", "14GUID236b0348a73-877c-4311-ba7c-e34b5cb0256f210TermTranNr1600000617BatchNr13001217termInfoFwVersion215V2.0.0.20211115219termInfoBatChgTimes110218termInfoRomVersion226V1.1.1.202111150949 INTLv7220termInfoSecFwVersion226X990-V1.0.12(202111221449)220termInfoTotCtlsCount1216220termInfoBatteryLevel13 69218termInfoActiveNetw14WIFI217termInfoHwVersion217M550-104-XX-XXX-5212termInfoIMEI215860162049678698218termInfoAppVersion217vfmpos2.1.0-beta3219termInfoTotMagCount1218216termInfoSerialNr210V1E0653476217termInfoIpAddress1910.11.2.5216termInfoLocation244-17.768301,31.024467,26.800001,1699257556000217termInfoTermModel14X990220termInfoTotChipCount110221termInfoSysSvcVersion161.11.2218termInfoApiVersion2112.1.0-beta3218termInfoSvcVersion183.11.2.1217termInfoOsVersion157.1.2");
        isoMsg.set(49, "932");
        isoMsg.set(52,  ISOUtil.hex2byte("B25CCEA90A659470"));
        isoMsg.set(53,  ISOUtil.hex2byte("A100203476E00003"));
        String field55Value = "FF2081CA9F02060000000002809F03060000000000004F07A0000007790000820218009F360200B79F0702FFC09F2608F041D289899BCECD9F2701808E0E0000000000000000020102031F039F34030203009F1E0845303635333447369F0D05008834F8009F0E053070C800009F0F05008834F8009F10200FA501A301C0000000000000000000000F0100000000000000000000000000009F090200969F330364D0C89F1A0207169F350122950580800480005F2A0209329A032311069F4104000000039C01009F3704CBE68AE7";
        isoMsg.set(55,  ISOUtil.hex2byte(field55Value));
        isoMsg.setPackager(packager);
        return sendRequest(isoMsg);
    }


And below is my sale log for the sale request:
    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.GenericPackager[file:packager/isotmp.xml] -->
      <field id="0" value="1200"/>
      <field id="3" value="000000"/>
      <field id="4" value="000000000280"/>
      <field id="7" value="1106022517"/>
      <field id="11" value="000013"/>
      <field id="12" value="231106102517"/>
      <field id="22" value="A10101513346"/>
      <field id="23" value="001"/>
      <field id="24" value="200"/>
      <field id="29" value="001"/>
      <field id="35" value="6079953000000474D33122260786909001"/>
      <field id="41" value="APOS0001"/>
      <field id="42" value="300041310020157"/>
      <isomsg id="48">
        <field id="1" value="APOS0001000013"/>
        <field id="16" value="14GUID236b0348a73-877c-4311-ba7c-e34b5cb0256f210TermTranNr1600000617BatchNr13001217termInfoFwVersion215V2.0.0.20211115219termInfoBatChgTimes110218termInfoRomVersion226V1.1.1.202111150949 INTLv7220termInfoSecFwVersion226X990-V1.0.12(202111221449)220termInfoTotCtlsCount1216220termInfoBatteryLevel13 69218termInfoActiveNetw14WIFI217termInfoHwVersion217M550-104-XX-XXX-5212termInfoIMEI215860162049678698218termInfoAppVersion217vfmpos2.1.0-beta3219termInfoTotMagCount1218216termInfoSerialNr210V1E0653476217termInfoIpAddress1910.11.2.5216termInfoLocation244-17.768301,31.024467,26.800001,1699257556000217termInfoTermModel14X990220termInfoTotChipCount110221termInfoSysSvcVersion161.11.2218termInfoApiVersion2112.1.0-beta3218termInfoSvcVersion183.11.2.1217termInfoOsVersion157.1.2"/>
      </isomsg>
      <field id="49" value="932"/>
      <field id="52" value="B25CCEA90A659470" type="binary"/>
      <field id="53" value="A100203476E00003" type="binary"/>
      <field id="55" value="FF2081CA9F02060000000002809F03060000000000004F07A0000007790000820218009F360200B79F0702FFC09F2608F041D289899BCECD9F2701808E0E0000000000000000020102031F039F34030203009F1E0845303635333447369F0D05008834F8009F0E053070C800009F0F05008834F8009F10200FA501A301C0000000000000000000000F0100000000000000000000000000009F090200969F330364D0C89F1A0207169F350122950580800480005F2A0209329A032311069F4104000000039C01009F3704CBE68AE7" type="binary"/>
    </isomsg>



    Any help to resolve this will be grately appreciate. I have aligned the items in the packager to that of the termapp.iso documentation.


    Kind regards

    Flavian






Andrés Alcarraz

unread,
Nov 6, 2023, 2:46:24 PM11/6/23
to jpos-...@googlegroups.com
Please, log the entire stack trace of an exception, not just its message, so you and us have more context.

Also, please send large chunks of code, like the packager configuration, as attachments and not inline. It makes the whole mail hard to read.

In addition, to make us easier to help you, please send a simple reproducible program, in this case you just need a small main that just packs the message.

Best regards.

Andrés Alcarraz

flavian machimbirike

unread,
Nov 6, 2023, 3:00:11 PM11/6/23
to jpos-...@googlegroups.com
Hi

Thank you for the quick response:

Below is the stacktrace:
<iso-exception>
      error packing field 48
      <iso-exception>
        org.jpos.iso.IF_CHAR: Problem packing field -1
        <nested-exception>
        java.lang.ClassCastException: java.util.BitSet cannot be cast to java.lang.String
at org.jpos.iso.ISOStringFieldPackager.pack(ISOStringFieldPackager.java:143)
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:135)
at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:90)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:74)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
        </nested-exception>
        org.jpos.iso.ISOException: org.jpos.iso.IF_CHAR: Problem packing field -1 (java.lang.ClassCastException: java.util.BitSet cannot be cast to java.lang.String)
at org.jpos.iso.ISOStringFieldPackager.pack(ISOStringFieldPackager.java:157)
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:135)
at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:90)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:74)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
Nested:java.lang.ClassCastException: java.util.BitSet cannot be cast to java.lang.String
at org.jpos.iso.ISOStringFieldPackager.pack(ISOStringFieldPackager.java:143)
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:135)
at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:90)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:74)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
      </iso-exception>
      org.jpos.iso.ISOException: error packing field 48 (org.jpos.iso.ISOException: org.jpos.iso.IF_CHAR: Problem packing field -1 (java.lang.ClassCastException: java.util.BitSet cannot be cast to java.lang.String))
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:185)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:90)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:74)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
Nested:org.jpos.iso.ISOException: org.jpos.iso.IF_CHAR: Problem packing field -1 (java.lang.ClassCastException: java.util.BitSet cannot be cast to java.lang.String)
at org.jpos.iso.ISOStringFieldPackager.pack(ISOStringFieldPackager.java:157)
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:135)
at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:90)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:74)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
Nested:java.lang.ClassCastException: java.util.BitSet cannot be cast to java.lang.String
at org.jpos.iso.ISOStringFieldPackager.pack(ISOStringFieldPackager.java:143)
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:135)
at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:90)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:74)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
    </iso-exception>
  </send>
</log>

Below is the main method:

package com.samsoftx.hsm.hsmclient;

import com.samsoftx.hsm.hsmclient.rest.JposController;
import lombok.extern.log4j.Log4j2;
import org.jpos.iso.ISOChannel;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
import org.jpos.iso.channel.NACChannel;
import org.jpos.iso.packager.GenericPackager;
import org.jpos.iso.packager.PackagerWrapper;
import org.jpos.iso.packager.PostPackager;
import org.jpos.util.LogSource;
import org.jpos.util.Logger;
import org.jpos.util.SimpleLogListener;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.IOException;
import java.net.SocketException;

import static org.jpos.iso.ISOMsg.OUTGOING;


@SpringBootApplication
@Log4j2
public class HsmClientApplication implements CommandLineRunner {

    //private final JposController jposController;
    private final GenericPackager packager;

    public HsmClientApplication(final JposController jposController) throws ISOException {
        this.packager = new GenericPackager("file:packager/isotmp.xml");
       // this.jposController = jposController;
    }

    public static void main(final String[] args) {
        SpringApplication.run(HsmClientApplication.class, args);

    }

    @Override
    public void run(String... args) throws Exception {
       //jposController.test();
        //jposController.launch();
       saleTransaction();
    private ISOMsg sendRequest(final ISOMsg isoMsg) throws Exception {


        log.info("########################### Sending Messages: {}");
        try {
            final Logger logger = new Logger();
            logger.addListener(new SimpleLogListener(System.out));

       
            final ISOChannel channel = new NACChannel("#", 9305, packager, ISOUtil.hex2byte("0"));


            ((LogSource) channel).setLogger(logger, "xml-server-9000");
            channel.connect();
            channel.send(isoMsg);
            final ISOMsg response = channel.receive();
            return response;
        } catch (final IOException | ISOException ex) {

Mark Salter

unread,
Nov 7, 2023, 1:55:34 AM11/7/23
to jpos-...@googlegroups.com
The code is trying g to build a bitmap for field 48 because you have not configured it not to. emitBitmap=false is needed in your configuration.

You also have a '9999' max length subfield inside a '999' wrapper, which might fail at some point and suggests a mistake reading the spec.
Your code is also setting Field 49 twice.



-- 
Mark


Sent from Proton Mail mobile



-------- Original Message --------
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CACSnBaivAPp8omG-XmLnVrPK5Y1XguBNYtHA%3Die7MM878v2PHA%40mail.gmail.com.
signature.asc

flavian machimbirike

unread,
Nov 7, 2023, 2:17:28 AM11/7/23
to jpos-...@googlegroups.com
Hi Mark 

I have adjusted the code as follow and have removed the duplicated F49: 
package com.samsoftx.hsm.hsmclient;

import com.samsoftx.hsm.hsmclient.rest.JposController;
import lombok.extern.log4j.Log4j2;
import org.jpos.iso.ISOChannel;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
import org.jpos.iso.channel.NACChannel;
import org.jpos.iso.packager.GenericPackager;
import org.jpos.iso.packager.PackagerWrapper;
import org.jpos.iso.packager.PostPackager;
import org.jpos.util.LogSource;
import org.jpos.util.Logger;
import org.jpos.util.SimpleLogListener;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.IOException;
import java.net.SocketException;

import static org.jpos.iso.ISOMsg.OUTGOING;


@SpringBootApplication
@Log4j2
public class HsmClientApplication implements CommandLineRunner {

  //  private final JposController jposController;
        isoMsg.set(52,  ISOUtil.hex2byte("B25CCEA90A659470"));
isoMsg.set(53, ISOUtil.hex2byte("A100203476E00003"));
String field55Value = "FF2081CA9F02060000000002809F03060000000000004F07A0000007790000820218009F360200B79F0702FFC09F2608F041D289899BCECD9F2701808E0E0000000000000000020102031F039F34030203009F1E0845303635333447369F0D05008834F8009F0E053070C800009F0F05008834F8009F10200FA501A301C0000000000000000000000F0100000000000000000000000000009F090200969F330364D0C89F1A0207169F350122950580800480005F2A0209329A032311069F4104000000039C01009F3704CBE68AE7";
isoMsg.set(55, ISOUtil.hex2byte(field55Value));
isoMsg.setPackager(packager);
return sendRequest(isoMsg);
}

private ISOMsg sendRequest(final ISOMsg isoMsg) throws Exception {

log.info("########################### Sending Messages: {}");
try {
final Logger logger = new Logger();
logger.addListener(new SimpleLogListener(System.out));

            // final ISOChannel channel = new NACChannel("197.211.198.153", 9305, new PostPackager(), null);
//final ISOChannel channel = new NACChannel("197.211.198.153", 9305, new PostPackager(), ISOUtil.hex2byte("0"));
final ISOChannel channel = new NACChannel("197.211.198.153", 9305, packager, ISOUtil.hex2byte("0"));


((LogSource) channel).setLogger(logger, "xml-server-9000");
channel.connect();
channel.send(isoMsg);
final ISOMsg response = channel.receive();
return response;
} catch (final IOException | ISOException ex) {
if (ex instanceof SocketException) {
log.info("########################### Issuer unavailable: {}", ex.getMessage());
}
log.info("########################### Failing to connect: {}", ex.getMessage());
throw new IOException("Failed to connect");
}
}
}


Below is the snippet from the packager:  NB: I have also adjusted the lengths as per your recommendation.
<isofieldpackager
id="48"
length="9999"
emitBitmap="false"
        name="Additional data - private"
        class="org.jpos.iso.IFA_LLLLCHAR"
        packager="org.jpos.iso.packager.GenericSubFieldPackager">
<isofield
id="1"
length="19"

name="POS DATA"
class="org.jpos.iso.IF_CHAR"/>

<isofield
id="16"
length="999"
            name="Structured Data"
class="org.jpos.iso.IFA_LLLCHAR"/>
</isofieldpackager>

Upon running it again am getting the following error: 
  <send>

    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.GenericPackager[file:packager/isotmp.xml] -->
      <field id="0" value="1200"/>
      <field id="3" value="000000"/>
      <field id="4" value="000000000280"/>
      <field id="7" value="1106022517"/>
      <field id="11" value="000013"/>
      <field id="12" value="231106102517"/>
      <field id="22" value="A10101513346"/>
      <field id="23" value="001"/>
      <field id="24" value="200"/>
      <field id="29" value="001"/>
      <field id="35" value="6079953000000474D33122260786909001"/>
      <field id="41" value="APOS0001"/>
      <field id="42" value="300041310020157"/>
      <isomsg id="48">
        <field id="1" value="APOS0001000013"/>
        <field id="16" value="14GUID236b0348a73-877c-4311-ba7c-e34b5cb0256f210TermTranNr1600000617BatchNr13001217termInfoFwVersion215V2.0.0.20211115219termInfoBatChgTimes110218termInfoRomVersion226V1.1.1.202111150949 INTLv7220termInfoSecFwVersion226X990-V1.0.12(202111221449)220termInfoTotCtlsCount1216220termInfoBatteryLevel13 69218termInfoActiveNetw14WIFI217termInfoHwVersion217M550-104-XX-XXX-5212termInfoIMEI215860162049678698218termInfoAppVersion217vfmpos2.1.0-beta3219termInfoTotMagCount1218216termInfoSerialNr210V1E0653476217termInfoIpAddress1910.11.2.5216termInfoLocation244-17.768301,31.024467,26.800001,1699257556000217termInfoTermModel14X990220termInfoTotChipCount110221termInfoSysSvcVersion161.11.2218termInfoApiVersion2112.1.0-beta3218termInfoSvcVersion183.11.2.1217termInfoOsVersion157.1.2"/>
      </isomsg>
      <field id="49" value="932"/>
      <field id="52" value="B25CCEA90A659470" type="binary"/>
      <field id="53" value="A100203476E00003" type="binary"/>
      <field id="55" value="FF2081CA9F02060000000002809F03060000000000004F07A0000007790000820218009F360200B79F0702FFC09F2608F041D289899BCECD9F2701808E0E0000000000000000020102031F039F34030203009F1E0845303635333447369F0D05008834F8009F0E053070C800009F0F05008834F8009F10200FA501A301C0000000000000000000000F0100000000000000000000000000009F090200969F330364D0C89F1A0207169F350122950580800480005F2A0209329A032311069F4104000000039C01009F3704CBE68AE7" type="binary"/>
    </isomsg>
    <iso-exception>
      error packing field 48
      <iso-exception>
        java.lang.NullPointerException
        <nested-exception>
        java.lang.NullPointerException
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:147)

at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:89)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:73)

at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
        </nested-exception>
        org.jpos.iso.ISOException: java.lang.NullPointerException (java.lang.NullPointerException)
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:173)

at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:89)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:73)

at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
Nested:java.lang.NullPointerException
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:147)

at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:89)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:73)

at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
      </iso-exception>
      org.jpos.iso.ISOException: error packing field 48 (org.jpos.iso.ISOException: java.lang.NullPointerException (java.lang.NullPointerException))

at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:185)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:89)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:73)

at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
Nested:org.jpos.iso.ISOException: java.lang.NullPointerException (java.lang.NullPointerException)
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:173)

at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:89)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:73)

at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
Nested:java.lang.NullPointerException
at org.jpos.iso.packager.GenericSubFieldPackager.pack(GenericSubFieldPackager.java:147)

at org.jpos.iso.ISOMsgFieldPackager.pack(ISOMsgFieldPackager.java:60)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:176)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:467)
at org.jpos.iso.BaseChannel.pack(BaseChannel.java:979)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:596)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.sendRequest(HsmClientApplication.java:89)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.saleTransaction(HsmClientApplication.java:73)

at com.samsoftx.hsm.hsmclient.HsmClientApplication.run(HsmClientApplication.java:46)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.samsoftx.hsm.hsmclient.HsmClientApplication.main(HsmClientApplication.java:39)
    </iso-exception>
  </send>
</log>



I am not sure where I am getting this wrong. Thanks again for the response

Mark Salter

unread,
Nov 7, 2023, 2:41:19 AM11/7/23
to jpos-...@googlegroups.com
After making those changes, is it working as expected or not ?



-- 
Mark


Sent from Proton Mail mobile



-------- Original Message --------
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CACSnBajZo1U_eE2bMgUK__ist%3DuYuxksGQdGsQkg%3DJtdejK6qw%40mail.gmail.com.
signature.asc

flavian machimbirike

unread,
Nov 7, 2023, 2:51:33 AM11/7/23
to jpos-...@googlegroups.com
It is not working as expected. It is still unable to pack F48, so I have pasted the stack trace. 

NB: The idea is to have f48 packed and then properly propagate the ISO request to postilion.  

Kind regards

Flavian 

Mark Salter

unread,
Nov 7, 2023, 12:34:09 PM11/7/23
to jpos-...@googlegroups.com
Hard to see the stack tracemom a mobile device with such long content.

Can you share the version of jpos you are using?

I will take a look on my pc at your post shortly.



-- 
Mark


Sent from Proton Mail mobile



-------- Original Message --------
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CACSnBag-gyyvbg_6JQpnWLkT_%3DvJ9NAe_vdcxT9ry7Xrh_HPcA%40mail.gmail.com.
signature.asc

flavian machimbirike

unread,
Nov 7, 2023, 12:38:27 PM11/7/23
to jpos-...@googlegroups.com
Hi Mark 

Currently using this version:
<dependency>
<groupId>org.jpos</groupId>
<artifactId>jpos</artifactId>
<version>2.1.6</version>
</dependency>
Thank you for your response. 

Kind regards

Flavian 

Mark Salter

unread,
Nov 7, 2023, 12:53:05 PM11/7/23
to jpos-...@googlegroups.com
On 07/11/2023 17:37, flavian machimbirike wrote:
Currently using this version:
<dependency>
    <groupId>org.jpos</groupId>
    <artifactId>jpos</artifactId>
    <version>2.1.6</version>
</dependency>

I am thinking it is because you have not defined field 2 through 15; but am not sure.


Can you run under debug and confirm what is null, or try renumber number 16 subfield to 2 temporarily (in packager definition and code) just to check.  If it works as '2' instead of '16', then define some dummy definitions for 2 through 15 (repeat sub field 1 since you are not setting for a quick try) and try again.

I can't say I have ever tried a generic packager with 'missing' or gaps in the sequence of subfield ids, but I think it might be that, so have a try as it is easier for you do/try than for me to make something up :-)

--

Mark

signature.asc

Mark Salter

unread,
Nov 8, 2023, 12:29:10 AM11/8/23
to jpos-...@googlegroups.com
Or add the missing subfield definitions if they really are defined by the target's specificarion but missing from your packager.

Can I check too? The subject says 'unpacking' but so far you seem to be producing a message and so are packing?


-- 
Mark


Sent from Proton Mail mobile



-------- Original Message --------
--
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/e7adf3e3-521d-4272-bad6-a685c3c6721e%40protonmail.com.
signature.asc
Reply all
Reply to author
Forward
0 new messages