I have the following IDL interface:
interface ItemA : Item {
void actionA(in float a, out long b);
};
In my Java implementation I'd like to invoke the operation actionA
dynamically (using DII). The item
object here implements Item
interface and therefore knows nothing about the actionA
. Here's the snippet:
org.omg.CORBA.Request r = item._request("actionA");
r.add_in_arg().insert_float(a);
// add the out argument
r.set_return_type(orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_void));
r.invoke();
// get the out argument result
How can I fill in those blanks? I've tried various approaches, mainly different uses of r.add_out_arg()
but nothing seems to work. I'd appreciate your help!
Try this:
org.omg.CORBA.Request r = item._request("actionA");
r.add_in_arg().insert_float(a);
Any val = r.add_out_arg();
val.type(orb.get_primitive_tc(TCKind.tk_long));
r.set_return_type(orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_void));
r.invoke();
if( r.env().exception() == null )
{
System.out.println("returned: " + r.arguments().item(1).value().extract_long());
}
It worked for me (I've already seen this idl somewhere...:P).