You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Rajesh Khan <ra...@gmail.com> on 2013/07/11 03:01:42 UTC
How to send binary messages with QPID
I am attempting to enclose a binary message in C++ and trying to receive it
at C#
here is what I am doing
in my c++
std::string ser = obj.SerializeAsString();
response.setContent(ser); //This is a message type;
and in C#
String resp = response.GetContent();
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(resp);
obj = obj.CreateBuilder().MergeFrom(bytes).Build();
any suggestion on what I might be doing wrong ? I am using google protocol
buffer from serializat in C++ and deserialization in C#
Re: How to send binary messages with QPID
Posted by Rajesh Khan <ra...@gmail.com>.
Thanks Gordon that did the trick.
On Thu, Jul 11, 2013 at 2:50 AM, Gordon Sim <gs...@redhat.com> wrote:
> On 07/11/2013 02:01 AM, Rajesh Khan wrote:
>
>> I am attempting to enclose a binary message in C++ and trying to receive
>> it
>> at C#
>> here is what I am doing
>> in my c++
>> std::string ser = obj.SerializeAsString();
>> response.setContent(ser); //This is a message type;
>>
>> and in C#
>>
>> String resp = response.GetContent();
>> byte[] bytes = System.Text.Encoding.UTF8.**GetBytes(resp);
>> obj = obj.CreateBuilder().MergeFrom(**bytes).Build();
>>
>
> Try changing the c# part to do:
>
> byte[] bytes;
> response.GetContent(bytes);
> obj = obj.CreateBuilder().MergeFrom(**bytes).Build();
>
> The 'string' you send from c++ is simply a sequence of bytes, not
> necessarily a utf8 string (and if its the google buffer serialised data its
> quite likely its not UTF8!).
>
>
> any suggestion on what I might be doing wrong ? I am using google protocol
>> buffer from serializat in C++ and deserialization in C#
>>
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.**org<us...@qpid.apache.org>
> For additional commands, e-mail: users-help@qpid.apache.org
>
>
Re: How to send binary messages with QPID
Posted by Gordon Sim <gs...@redhat.com>.
On 07/11/2013 02:01 AM, Rajesh Khan wrote:
> I am attempting to enclose a binary message in C++ and trying to receive it
> at C#
> here is what I am doing
> in my c++
> std::string ser = obj.SerializeAsString();
> response.setContent(ser); //This is a message type;
>
> and in C#
>
> String resp = response.GetContent();
> byte[] bytes = System.Text.Encoding.UTF8.GetBytes(resp);
> obj = obj.CreateBuilder().MergeFrom(bytes).Build();
Try changing the c# part to do:
byte[] bytes;
response.GetContent(bytes);
obj = obj.CreateBuilder().MergeFrom(bytes).Build();
The 'string' you send from c++ is simply a sequence of bytes, not
necessarily a utf8 string (and if its the google buffer serialised data
its quite likely its not UTF8!).
> any suggestion on what I might be doing wrong ? I am using google protocol
> buffer from serializat in C++ and deserialization in C#
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org