Search code examples
javaiso8583jpos

how to encode and send ISO 8583 message with ASCII and Hexa?


i have to send a message like this :

Entete(hexadecimal)+ MTI(Ascii)+bitmap (hexadecimal)+DE11(Ascii)+DE12(Ascii)+DE24(Ascii)

so far i was using ASCIIChannel to send my ISO messages with jpos library.

here is an example of the message i would like to send (echo test).

ISOPackager packager = new GenericPackager(ISOUtils.getAbsolutePathOfAFile("./packager/iso8583packager.xml"));
    ISOMsg isoMsg = new ISOMsg();
    ISOMsg subIsoMsg = new ISOMsg();
    isoMsg.setPackager(packager);
    isoMsg.setHeader("00100101".getBytes());
    isoMsg.set("0","1804");
    isoMsg.set("1","100000000000000000000001");
    isoMsg.set("11","678897");
    isoMsg.set("12","230107100923");
    isoMsg.set("24","831");

ASCIIChannel channel = new ASCIIChannel("127.0.0.1", 5000, packager);
    //RawChannel channel = new RawChannel("192.168.1.101", 5000, packager);
    channel.connect();
    channel.send(isoMsg);

how can i do to send message with ASCII encoding and hexa ?

EDIT : here is the package used :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager PUBLIC
        "-//jPOS/jPOS Generic Packager DTD 1.0//EN"
        "http://jpos.org/dtd/generic-packager-1.0.dtd">

<!-- ISO 8583:1993 (ASCII) field descriptions for GenericPackager -->

<isopackager>
  <isofield
          id="0"
          length="4"
          name="Message Type Indicator"
          class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
          id="1"
          length="16"
          name="Bitmap"
          class="org.jpos.iso.IFA_BITMAP"/>
  <isofield
          id="2"
          length="19"
          name="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="Date and time, transmission"
          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="Systems trace audit number"
          class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
          id="12"
          length="12"
          name="Date and time, Local transaction"
          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"
          class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
          id="15"
          length="6"
          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="Merchant type"
          class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
          id="19"
          length="3"
          name="Country code, Acquiring institution"
          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 data code"
          class="org.jpos.iso.IF_CHAR"/>
  <isofield
          id="23"
          length="3"
          name="Card sequence number"
          class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
          id="24"
          length="3"
          name="Function code"
          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="Acquirer institution identification code"
          class="org.jpos.iso.IFA_LLNUM"/>
  <isofield
          id="33"
          length="11"
          name="Forwarding institution identification 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="Action code"
          class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
          id="40"
          length="3"
          name="Service code"
          class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
          id="41"
          length="8"
          name="Card acceptor terminal identification"
          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="99"
          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="255"
          name="Additional Data"
          class="org.jpos.iso.IFA_LLLCHAR"
          emitBitmap="false"
          firstField="2"
          packager="org.jpos.iso.packager.GenericSubFieldPackager">
    <isofield
            id="2"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="3"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="4"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="5"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="6"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="7"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="8"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="9"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="10"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="11"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
    <isofield
            id="12"
            length="8"
            name="first field"
            class="org.jpos.iso.IFA_LLLCHAR"/>
  </isofieldpackager>
  <isofield
          id="49"
          length="3"
          name="Currency code, Transaction"
          class="org.jpos.iso.IF_CHAR"/>
  <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="Personal identification number [PIN] data"
          class="org.jpos.iso.IFA_BINARY"/>
  <isofield
          id="53"
          length="48"
          name="Security related control information"
          class="org.jpos.iso.IFA_LLBINARY"/>
  <isofield
          id="54"
          length="120"
          name="Amounts, additional"
          class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
          id="55"
          length="255"
          name="IC card system related data"
          class="org.jpos.iso.IFA_LLLBINARY"/>
  <isofield
          id="56"
          length="35"
          name="Original data elements"
          class="org.jpos.iso.IFA_LLNUM"/>
  <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="Reserved for national use"
          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="Country code, authorizing agent Inst."
          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 Dest. Inst. Id code"
          class="org.jpos.iso.IFA_LLNUM"/>
  <isofield
          id="94"
          length="11"
          name="Transaction Orig. Inst. 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_LLCHAR"/>
  <isofield
          id="103"
          length="28"
          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="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="999"
          name="Reserved for private use"
          class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
          id="128"
          length="8"
          name="Message authentication code field"
          class="org.jpos.iso.IFA_BINARY"/>
</isopackager>

here is the template of the message i have to constitute (from a tcpdump):

09:34:50.321783 -| 
31.38.30.34.00.30.01.00.00.00.00.00.30.39.30.37       1804.0......0907
09:34:50.321794 -| 34.38.32.33.30.32.30.38.30.39.30.37.34.38.38.33       4823020809074883
09:34:50.321803 -| 31                                                    1
09:34:50.321813 D|

update : the server side code (with the same packager):

@Component
public class Server implements ISORequestListener{

@Bean
public void iniTServer() throws ISOException {
    String hotname = "127.0.0.1";
        int portNumber = 5000;
        ISOPackager packager = new GenericPackager(Server.getAbsolutePathOfAFile("./packager6/iso8583packager.xml"));
        PostChannel channel = new PostChannel(hotname, portNumber, packager);
        ISOServer server = new ISOServer(portNumber, channel, null);
        server.addISORequestListener(new Server());
        System.out.println("ISO8583 server started...");
        new Thread(server).start();
}

 @Override
    public boolean process(ISOSource isoSource, ISOMsg isoMsg) {
        try {
            System.out.println("ISO8583 incoming message on host [" + ((BaseChannel) isoSource).getSocket().getInetAddress().getHostAddress() + "]");
            receiveMessage(isoSource, isoMsg);
            printISOMessage(isoMsg);
            System.out.println("ISO Message: " + isoMsg);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return true;
    }

    private void receiveMessage(ISOSource isoSource, ISOMsg isoMsg) throws ISOException, IOException, ISOException, CsvException, URISyntaxException {
        System.out.println("ISO8583 Message received...");
        InputStreamReader reader = FileUtils.loadFile("/BDD.csv", getClass());
        URL url = getClass().getResource("/BDD.csv");
        File file = new File(url.toURI());
        file.setWritable(true);
        CSVReader csvReader = new CSVReader(reader);
        //reader.close();
       List<String[]> records=csvReader.readAll();
       // Object obj=jo.parse(reader2); 
       FileUtils.csvUpdaterAtAnIndex(getClass(),csvReader, "99", "/BDD.csv", 1, 2);
        //String jsonString=gson.toJson(obj);
        //JSONObject jsonObj=new JSONObject(jsonString);
        Response resp=new Response();
        
        resp.setDataFields(IsoUtils2.buildResponseFromISOMessage(isoMsg));
        ISOMsg isoResponse=new ISOMsg();
        String response="";
        String soldeClient=records.get(1)[2];
        isoResponse=IsoUtils2.buildResponseToSend(isoMsg, soldeClient, resp);
        //System.out.println("isoResponse "+isoResponse);
        isoSource.send(isoResponse);
    }

    private static void printISOMessage(ISOMsg isoMsg) throws ISOException {
        System.out.printf("MTI = %s%n", isoMsg.getMTI());
    for (int i = 1; i <= isoMsg.getMaxField(); i++) {
        if (isoMsg.hasField(i)) {
            System.out.printf("Field (%s) = %s%n", i, isoMsg.getString(i));
         }
        }
    }

public static String getAbsolutePathOfAFile(String relativePath){
    return Paths.get(relativePath).toAbsolutePath().normalize().toAbsolutePath().toString();
}

}


Solution

  • As detailed in the comments the OP wants the message length to be sent as two bytes in network byte order. For that, PostChannel does the job.

    This modified code should work as a proof of concept, although I would suggest using Q2 to start and configure the channel following the first two jPOS tutorials and the jPOS programmers guide section 5: Channels.

    Also, you don't need to set the bitmap field, it is generated by the packager based on the present fields.

        ISOPackager packager = new GenericPackager(ISOUtils.getAbsolutePathOfAFile("./packager/iso8583packager.xml"));
        ISOMsg isoMsg = new ISOMsg();
        isoMsg.setPackager(packager);
        isoMsg.set("0","1804");
        isoMsg.set("11","678897");
        isoMsg.set("12","230107100923");
        isoMsg.set("24","831");
    
        ISOChannel channel = new PostChannel("127.0.0.1", 5000, packager);
        channel.connect();
        channel.send(isoMsg);
    

    You'll also need to configure the bitmap as binary in the packager:

      <isofield
              id="1"
              length="16"
              name="Bitmap"
              class="org.jpos.iso.IFB_BITMAP"/>