[omniORB] Using cdrMemoryStream?

Duncan Grisby duncan at grisby.org
Thu Jul 21 18:46:23 BST 2005


On Thursday 21 July, amos at amos.mailshell.com wrote:

> I'm trying to serialize an object created locally on the
> server into a file. (the aim is to read that object later
> from the file and send it to CORBA clients upon request
> as a function's return value).
> 
> I tried the following ("op" is the object I want to
> serialize):

It would be really helpful if you gave us the IDL definitions of your
types. Otherwise we have to guess from the code, which isn't very easy.
Certainly "op" is not an object by the CORBA usage of the word. I guess
it's a union...

> operationslog::Operation op;
> op._d(0);
> operationslog::AddRealmOp addRealmOp;
> addRealmOp.id = id;
> addRealmOp.name = name;
> op.addRealm(addRealmOp);
> cdrMemoryStream stream;
> 	
> op >>= stream;
> cout << "addRealm: stream: buffer size: " << stream.bufSize() << endl;
> 
> But apparently this causes the operation to abort.

In what way does it abort?

Have you initialised the ORB?  Guessing that name is a string or
wstring, marshalling it requires that the ORB has been initialised, so
the code set conversion support is initialised.

On an side note, what are you going to do with the value once you've
marshalled it?  If you're going to store it somewhere, remember that the
marshalled form depends on the byte order of the platform. If you want
to be immune to problems with that, you might want to use a
cdrEncapsulationStream, which adds a bit of overhead, but handles the
byte order issues for you.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list