2 Replies Latest reply: Feb 24, 2010 11:00 PM by EJP RSS

    Serializing a CORBA object into a buffer

    843790
      Probably asked a million times but I haven't found it yet. How does one flatten an arbitrary CORBA Object to e.g. a byte[] without writing a pile of code to reinvent what the ORB has to do anyway?

      I've tried the normal way of wrapping a ByteArrayOutputStream in an ObjectOutputStream and calling writeObject on that. Passing a TypeCode causes writeObject to throw NotSerializableException, while an Any containing a String results in an IOException whose message is merely the name of the package where it gave up. I guess that's the wrong approach for CORBA.

      CORBA has its own org.omg.CORBA.portable.OutputStream (extends java.io.OutputStream) which looks like it should do what I want, and I've seen hints that people have used it that way, but I haven't found any example code, and I haven't found any way to specify where the output goes. What have I missed?

      I want this because I'm writing a TradingService and so I need to store arbitrary objects in the database. I don't have any control of this; OMG already wrote the spec. I've begun working up methods that disassemble TypeCodes to XML and reconstitute therefrom, but I really don't want to go there.