activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Gomes <>
Subject Re: sending ObjectMessage between C# and Java
Date Wed, 16 Feb 2011 15:06:59 GMT
The NMS API has some good support for automatically serializing C# objects
into XML format and back out into objects.  You can refer to the
XmlMessageTest.cs unit test in the Apache.NMS project for some sample code
on how to go about this.

If you are using the .NET 3.5 assemblies (or later version, or Mono), then
there are several extension methods that make the syntax very nice.  The
XmlMessageTest.cs file shows two examples -- one using extension methods
(the preferred way), and one without, for .NET 2.0 and earlier.

I use these functions heavily to pass objects back and forth between C# and

On Wed, Feb 16, 2011 at 6:27 AM, Adam Kaminiecki <> wrote:

> Hi.
> You are right. After investigation a can tell you now and Im SURE Its
> impossible to send ObjectMessage between clients (C# is not able to get body
> from this type of message in Java it is possible after workaround :) ). Only
> solution is serialize object to XML and then send it as TextMessage. Thats
> work fine!
> Regards,
> Adam
> W dniu 2011-02-16 12:49, Timothy Bish pisze:
>  On Wed, 2011-02-16 at 11:31 +0100, Adam Kaminiecki wrote:
>>> Hi,
>>> Can anybody tell me how to get body form ObjectMessage in C#  or
>>> properly send from Java??
>>> Everything work ok for TextMessage but when I send  text message from
>>> Java in ObectMessage in C# client occur an error
>>> where IMessage m
>>> ((IObjectMessage) m).Body = '((IObjectMessage) m).Body' threw an
>>> exception of type 'System.Runtime.Serialization.SerializationException'
>>> System.SystemException {base} = {"input stream is not a valid binary
>>> format. The content of the initial (in bytes):.......
>>> But when I send From C# it is ok.
>>>  C# cannot de-serialize a java Object, it doesn't know anything about the
>> byte java types or how they are encoded.  You can send C# objects to C#
>> clients if they know about the type you are sending but that's the limit
>> of what you can do with ObjectMessage in C#.
>> If you really need to send objects then you should look into using
>> something like XStream to convert them to XML and then parse the XML on
>> the C# side.
>> Regards
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message