Config:
<template type="0500">
<field num="3" type="NUMERIC" length="6">920000</field>
<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" />
</template>
Code:
MessageFactory mfact = ConfigParser
.createFromClasspathConfig("config.xml");
mfact.setTraceNumberGenerator(new SimpleTraceGenerator((int) (System.currentTimeMillis() % 100000)));
m = mfact.newMessage(0x500);
m.setValue(24, 109, IsoType.NUMERIC, 3);
m.setValue(41, "10986312", IsoType.ALPHA, 8);
m.setValue(42, "000001106020132", IsoType.ALPHA, 15);
String strMsg = new String(msg.writeData());
strMsg
is giving me this result:
05 00 20 20 01 00 00 C0 00 00 92 00 00 04 42 18 10 91 09 86 31 20 00 00 11 06 02 01 32
but the result should be:
05 00 20 20 01 00 00 C0 00 00 92 00 00 04 42 18 01 09 31 30 39 38 36 33 31 32 30 30 30 30 30 31 31 30 36 30 32 30 31 33 32
where:
field 24 => 109 should be 0109
field 41 => 10986312 should be in hex 3130393836333132
feild 42 => 000001106020132 should be in hex 303030303031313036303230313332
Both field 41 and 42 are Alpha Numeric Special Character field.
Should I use HexCodec.hexEncode
whole message of part of the message before sending to the host using TCP/IP?