isoiso8583j8583

hexadecimal format for message IS08583 in the server side


Actually i'm working with iso 8583 messages, and library j8583 in java.

I created a echo (0800) message to probe connection with the server, the message looks good when is printed, but in the server side the message looks like hexadecimal encoding, something like this:

enter image description here

The devs in the server side told me is a format error for message, the correct message will be like this:

enter image description here

I see the correct message format are transmitted clearly like above image.

Factory from xml field:

this.messageFactory = ConfigParser.createFromClasspathConfig("j8583-config.xml");

Iso message setting binary flags

req.setBinaryFields(true);
req.setBinaryHeader(true);

XML configuration:

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE j8583-config PUBLIC "-//J8583//DTD CONFIG 1.0//EN" "http://j8583.sourceforge.net/j8583.dtd">
<j8583-config>

        <!-- These are the ISO headers to be prepended to the message types specified -->
        <header type="0800">6000050000</header>
        <header type="0810">6000050000</header>

        <template type="0800">
                <field num="3" type="NUMERIC" length="6" />
                <field num="7" type="DATE10" />
                <field num="11" type="NUMERIC" length="6" />
                <field num="24" type="NUMERIC" length="3" />
                <field num="41" type="ALPHA" length="8" />
                <field num="42" type="ALPHA" length="15" />
                <field num="60" type="LLLLVAR" length="" />
        </template>


        <parse type="0800">
                <field num="3" type="NUMERIC" length="6" />
                <field num="7" type="DATE10" />
                <field num="11" type="NUMERIC" length="6" />
                <field num="24" type="NUMERIC" length="3" />
                <field num="41" type="ALPHA" length="8" />
                <field num="42" type="ALPHA" length="15" />
                <field num="60" type="LLLLVAR" length="" />
        </parse>


</j8583-config>

IsoMessage build:

        final IsoMessage req = this.messageFactory.newMessage(NET_INFO_REQUEST.getValue());

        req.setValue(PROCESSING_CODE, ECHO.getValue(), IsoType.NUMERIC, 6);
        req.setValue(TRANSMISSION_DATE_TIME, FormatUtils.formatDate10GMT0(new Date()), IsoType.DATE10, 0);    
        req.setValue(SYSTEM_TRACE_AUDIT_NO, leftPad(simpleTraceGenerator.nextTrace(), 6), IsoType.NUMERIC, 6);    
        req.setValue(INTERNATIONAL_NETWORK_ID, command.VISA.getCode(), IsoType.NUMERIC, 4);
        req.setValue(TERMINAL_ID, "72024092", IsoType.ALPHA, 8);    
        req.setValue(CLIENT_CODE, "03659307       ", IsoType.ALPHA, 15);    
        req.setValue(SOFTWARE_VERSION, "OPv1", IsoType.LLLLVAR, 0);
        req.setBinary(fale);

Can help me?


Solution

  • Seems there's more than one problem with the message you're generating:

    1. You set fields and headers to binary, but the bitmap is still encoded in ASCII. You should probably just call setUseBinaryMessages instead, IIRC it sets all the messages flags to binary (bitmap, headers, fields). If it doesn't then you need to set binary bitmap programmatically (there's another method for that).
    2. You have a message header for the 0800 but from the hexdump that the other side expects, it seems it's either very different (probary binary, BCD encoded) or they don't expect a header at all. If you need a binary header, specify it in the config (binary header content should be specified as hex, e.g. <header type="800" binary="true">60011200</header>) or you can set it programatically.
    3. For the BCD-encoded fields, just use NUMERIC fields; the values will be BCD-encoded when using binary format. Same goes for DATE fields. LVAR fields are encoded as text; if you need binary data in those, then use LBIN instead. The binary equivalent of ALPHA is BINARY.
    4. LBCDBIN fields are only useful if you message is ASCII-encoded but you need a LBIN field with BCD-encoded length header, because the length header encoding is otherwise chosen based on the encoding of the message (BCD for binary messages, ASCII otherwise).

    Hope that helps!