ISOMsg resp = new ISOMsg();
resp.setMTI("0210");
byte b[] = { 00, ((byte) 0xfb) };
resp.setHeader(b);
resp.set(3, ("000000"));
resp.set(11, ("000003"));
resp.set(12, ISODate.getTime(new Date()));
resp.set(13, ISODate.getDate(new Date()));
resp.set(39, "00");
ASCIIChannel serverChannel = new ASCIIChannel(new ISO87APackager());
serverChannel.setHeader(new byte[2]);
ISOServer server = new ISOServer(6789, serverChannel, new ThreadPool(1, 100));
Thread t = new Thread(server);
t.start();
Logger logger = new Logger();
logger.addListener(new SimpleLogListener(System.out));
ASCIIChannel channel = new ASCIIChannel("localhost", 6789, new ISO87APackager());
channel.setHeader(new byte[2]);
((LogSource) channel).setLogger(logger, "test-channel");
channel.connect();
ISOMsg m = new ISOMsg();
m.setMTI("0200"); // I'm setting MTI code
byte b1[] = { 00, ((byte) 0xff) };
m.setHeader(b1);
m.set(3, "000000");
m.set(11, "000002");
m.set(12, ISODate.getTime(new Date()));
m.set(13, ISODate.getDate(new Date()));
m.set(41, "00000001");
m.set(60, "LUIS");
channel.send(m);
server.getLastConnectedISOChannel().send(resp);
ISOMsg r = channel.receive();
System.out.println("Client Input : ");
channel.disconnect();
System.out.println("");
Redirecting direct email to list.
---------- Forwarded message ----------
From: "chhil"
Date: Apr 11, 2014 10:18 PM
Subject: Re: MTI not available and unpacking field problems
To: "Luis Alberto Velez" <java...@gmail.com>
Cc:
> Look at the asciichannel source code and look at how the message length is prepended to the message.
> You may need to write your own channel class that extends the base channel class and prepends the message correctly while packing and understands the bytes when unpacking the message.
>
> What's the correlation between field 60 and the first 2 bytes in the message ?
>
> -chhil
>
> On Apr 11, 2014 9:56 PM, "Luis Alberto Velez" wrote:
>>
>> Hi Chhil, thanks for your answer. Works great.
>>
>> Now I'm getting this error: Invalid message length
>>
>> I receive data from a Spectra T800 and the terminal software provider told me that the header may vary depending on the data in field 60, ex:
>>
>> Message 1
>> 0000 00 d0 02 00 20 38 00 00 00 80 00 10 00 00 00 00 .... 8..........
>> 0010 00 15 09 50 59 04 11 32 41 30 30 31 36 35 34 01 ...PY..2A001654.
>> 0020 77 39 32 35 34 30 39 34 36 7c 70 61 62 6c 6f 7c w92540946|pablo|
>> 0030 41 70 65 72 74 75 72 61 7c 35 30 30 7c 32 30 31 Apertura|500|201
>> 0040 34 2f 30 33 2f 33 31 3b 39 32 35 34 30 39 34 36 4/03/31;92540946
>> 0050 7c 70 61 62 6c 6f 7c 50 65 72 47 6c 69 63 65 6d |pablo|PerGlicem
>> 0060 69 6e 61 7c 32 30 30 30 7c 32 30 31 34 2f 30 33 ina|2000|2014/03
>> 0070 2f 33 31 3b 39 32 35 34 30 39 34 36 7c 70 61 62 /31;92540946|pab
>> 0080 6c 6f 7c 45 78 61 50 65 72 69 6f 64 69 63 6f 7c lo|ExaPeriodico|
>> 0090 33 30 30 30 7c 32 30 31 34 2f 30 33 2f 33 31 3b 3000|2014/03/31;
>> 00a0 39 32 35 34 30 39 34 36 7c 70 61 62 6c 6f 7c 42 92540946|pablo|B
>> 00b0 6f 6c 65 74 61 52 69 66 61 28 45 79 42 69 63 29 oletaRifa(EyBic)
>> 00c0 7c 2d 31 30 30 30 7c 32 30 31 34 2f 30 33 2f 33 |-1000|2014/03/3
>> 00d0 31 3b 1;
>>
>>
>> Message 2
>> 0000 00 6d 02 00 20 38 00 00 00 80 00 10 00 00 00 00 .m.. 8..........
>> 0010 00 72 10 03 59 04 11 32 41 30 30 32 30 34 36 00 .r..Y..2A002046.
>> 0020 78 32 30 30 30 30 30 30 7c 63 61 6d 69 6c 6f 7c x2000000|camilo|
>> 0030 41 70 65 72 74 75 72 61 7c 35 30 30 7c 32 30 31 Apertura|500|201
>> 0040 34 2f 30 34 2f 31 31 3b 31 30 30 30 30 30 30 7c 4/04/11;1000000|
>> 0050 6a 6f 69 6e 65 72 7c 41 70 65 72 74 75 72 61 7c joiner|Apertura|
>> 0060 35 30 30 7c 32 30 31 34 2f 30 34 2f 31 31 3b 500|2014/04/11;
>>
>>
>> Each header of each message may be different, how can i handle this?
>>
>> Thanks!
>>
>>
>>>
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/534C4437.5070909%40talktalk.net.
--
--
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
Join us in IRC at http://webchat.freenode.net/?channels=jpos
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
---
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.
For more options, visit https://groups.google.com/d/optout.
What is the channel used by the server?
What is the packager used by the server?
What is the channel used by the client?