Sending and Receiving byte streams

700 views
Skip to first unread message

sunnyben

unread,
Jul 7, 2011, 5:04:18 AM7/7/11
to jPOS Users
Hi everyone,

I have a requirement to send my ISO messages as byte streams. When I
send the message as bytes -

channel.send(m.getBytes())

I get the following error message:

Exception in thread "main" org.jpos.iso.ISOException: N/A in Composite
at org.jpos.iso.ISOComponent.getBytes(ISOComponent.java:94)
at com.access.jpos.Test.main(Test.java:129)

And when I set the field values as bytes:

m.set(fld, stringValue.getBytes());

I get the following error message:

Exception in thread "main" org.jpos.iso.ISOException:
org.jpos.iso.IFB_NUMERIC: Problem packing field 0
(java.lang.ClassCastException: [B cannot be cast to java.lang.String)
at
org.jpos.iso.ISOStringFieldPackager.pack(ISOStringFieldPackager.java:
150)
at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:94)
at org.jpos.iso.ISOMsg.pack(ISOMsg.java:405)
at com.access.jpos.Test.main(Test.java:129)

I use ISO87BPackager and even set the packager before sending -
m.setPackager(new ISO87BPackager());


Any help will be appreciated.

Mark Salter

unread,
Jul 7, 2011, 6:19:59 AM7/7/11
to jpos-...@googlegroups.com
On 07/07/2011 10:04, sunnyben wrote:
> I have a requirement to send my ISO messages as byte streams.
This is always what happens, so it should be straightforward...

> When I send the message as bytes -
>
> channel.send(m.getBytes())
>
> I get the following error message:
>
> Exception in thread "main" org.jpos.iso.ISOException: N/A in Composite
> at org.jpos.iso.ISOComponent.getBytes(ISOComponent.java:94)
> at com.access.jpos.Test.main(Test.java:129)
>

This is test code, perhaps using the examples in the Programmers guide
would be a good place to start you off?

From here, we can't tell what is in your ISOMsg, your fields, amongst
other things.


> And when I set the field values as bytes:
>
> m.set(fld, stringValue.getBytes());

m.set(fld,stringValue) should work, but it depends on which field number
and which packager you are trying to set here.


>
> I get the following error message:
>
> Exception in thread "main" org.jpos.iso.ISOException:
> org.jpos.iso.IFB_NUMERIC: Problem packing field 0
> (java.lang.ClassCastException: [B cannot be cast to java.lang.String)
> at
> org.jpos.iso.ISOStringFieldPackager.pack(ISOStringFieldPackager.java:
> 150)
> at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:94)
> at org.jpos.iso.ISOMsg.pack(ISOMsg.java:405)
> at com.access.jpos.Test.main(Test.java:129)
>
> I use ISO87BPackager and even set the packager before sending -
> m.setPackager(new ISO87BPackager());

What data are you putting in which field number in the ISOMsg? How?

It looks to me that a pack time, the field is expecting a String and you
have given it a byte[].

The ISOMsg and Packager take care of any conversion for you, once you
have the right packager, almost all of your code interactions with the
ISOMsg will be using Strings.

> Any help will be appreciated.
>

Get the programmers guide, search this list, ask smart questions ( a
link to a guide to asking them, you will find in your search)...

--
Mark

Reply all
Reply to author
Forward
0 new messages