dcsimg
Insertion of user defined structure in CORBA ANY
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Gurpreet_Sachdeva
Posted On:   Wednesday, August 31, 2005 11:55 PM

I am using JDK 1.4.2 CORBA (ORB) APIs. I am using CORBA Any in my application. I am able to insert primitive values like short, long, char, etc. into the Any using the specified APIs. But if I try to insert a user defined structure, I get an exception. This can be explained further by the code below: Consider the following IDL definition: // IDL struct Foo { string bar; float number; }; interface Flexible { void doit (in any a); } Now in order to pass the structure Foo in Any, I use the following code snippet:    More>>

I am using JDK 1.4.2 CORBA (ORB) APIs.


I am using CORBA Any in my application. I am able to insert primitive values like short, long, char, etc. into the Any using the specified APIs. But if I try to insert a user defined structure, I get an exception.


This can be explained further by the code below:


Consider the following IDL definition:



// IDL
struct Foo {
string bar;
float number;
};



interface Flexible {
void doit (in any a);
}


Now in order to pass the structure Foo in Any, I use the following code snippet:



// Java
// Client.java,


import org.omg.CORBA.*;


Flexible fRef;


Any param = ORB.init().create_any();


Foo toPass = new Foo();



toPass.bar = "Bar";


toPass.number = (float) 34.5;


try {


fRef = FlexibleHelper.bind("anyMarker:anyServer", hostname);


fooHelper.insert (param, toPass);


fref.doit (param);


}


catch (Exception e) {


...


}


But I get an exception when I use the above mentioned methodology.


What is that I am doing wrong.


Or is there some known issue with Sun Java ORB.

   <<Less
About | Sitemap | Contact