[jacorb-developer] CORBA Any Serialization and Deserialization

Nick Cross jacorb at goots.org
Mon Mar 24 23:36:31 CET 2014



It should be possible to use a blank output stream from the ORB to write 
the Any to (and then write the bytes to the file) and read it back as 
you have done.

Is this what you are after : 
https://github.com/rnc/JacORB/commit/4fdb09f9bd6660382b3168e91bef6578521fd395 


Regards

Nick


On 24/03/14 19:38, Chun Tat David Chu wrote:
> Hi Jurgen,
>
> Thanks for the pointer.
> I also saw an internal
> org.jacorb.orb.portableInterceptor.Codec_CDR_1_0_Impl class that seems to
> be able to serve my needs as well.
>
> Although I believe the example code you've is more portable.
>
> Thank you,
>
> David
>
>
> On Mon, Mar 24, 2014 at 2:36 PM, Jürgen Weber <juergen at jwi.de> wrote:
>
>> See the comment At
>> http://www.hascode.com/2014/03/using-apache-avro-with-java-and-maven/
>>   Am 24.03.2014 18:52 schrieb "Chun Tat David Chu" <
>> beyonddc.storage at gmail.com>:
>>
>>> Hi All,
>>>
>>> I am currently using JacORB 3.2.  I have a requirement where I need to
>>> serialize a CORBA Any, write it to a file and then read it back as a
>> CORBA
>>> Any.
>>>
>>> For the CORBA Any Serialization, I wrote the following code:
>>>      org.omg.CORBA.portable.InputStream in =
>> anyData.create_input_stream();
>>>      byte[] byteArray = IOUtils.toByteArray(in);
>>>      FileUtils.writeByteArrayToFile(new File(msgDestination), byteArray);
>>>
>>> When converting the byte array back to CORBA Any, I did the following:
>>>      byte[] messageByte = FileUtils.readFileToByteArray(message);
>>>      org.jacorb.orb.CDRInputStream inputStream =
>>>              new org.jacorb.orb.CDRInputStream(this.orb, messageByte);
>>>      Any anyData = inputStream.read_any();
>>>
>>> However I encountered an ArrayIndexOutOfBoundsException that is thrown by
>>> the read_any() method.
>>>      java.lang.ArrayIndexOutOfBoundsException: 4
>>>          at
>>> org.jacorb.orb.CDRInputStream.read_octet(CDRInputStream.java:1105)
>>>          at org.jacorb.orb.Any.read_value(Any.java:1202)
>>>          at
>> org.jacorb.orb.CDRInputStream.read_any(CDRInputStream.java:667)
>>>
>>> That led me think that I probably did something wrong in the code.  Can
>>> anyone lead me to the right path on serializing and deserializing CORBA
>>> Any?
>>>
>>> Thanks,
>>>
>>> David
>>> _______________________________________________
>>> jacorb-developer maillist  -
>>> jacorb-developer at lists.spline.inf.fu-berlin.de
>>> https://lists.spline.inf.fu-berlin.de/mailman/listinfo/jacorb-developer
>>>
>> _______________________________________________
>> jacorb-developer maillist  -
>> jacorb-developer at lists.spline.inf.fu-berlin.de
>> https://lists.spline.inf.fu-berlin.de/mailman/listinfo/jacorb-developer
>>
> _______________________________________________
> jacorb-developer maillist  -  jacorb-developer at lists.spline.inf.fu-berlin.de
> https://lists.spline.inf.fu-berlin.de/mailman/listinfo/jacorb-developer
>



More information about the jacorb-developer mailing list