Request req = obref._request( "OperationName" );
req.add_in_arg().insert_long( 1245 ); req.add_in_arg().insert_float( 1245.678 ); req.add_in_arg().insert_boolean( true ); req.add_in_arg().insert_string( "String value" );Similar versions of the above insert methods exist for the other predefined CORBA types, as well.
typedef sequence<long> longs;the IDL compiler generates two auxiliary classes called longsHelper and longsHolder which are declared in the files longsHelper.java and longsHolder.java, respectively. These classes are placed in a separate Java package, called INTPackage (as a result, the generated files are placed in the subdirectory INTPackage of the directory where the IDL compiler generates code). You must remember to import the contents of this package with the import directive of Java when using these auxiliary calsses. The longsHelper class provides a static method called insert which can be used to insert a vector of long values into an object of type Any. A suitable call looks like this:
longsHelper.insert( req.add_in_arg(), array_of_longs );Note that you should add arguments (using the add_in_arg, add_out_arg, or add_inout_arg methods) in the same order as declared in the IDL interface.
req.set_return_type( orb.get_primitive_tc( org.omg.CORBA.TCKind.tk_boolean ) );Other types my be obtained by using
org.omg.CORBA.TCKind.tk_boolean org.omg.CORBA.TCKind.tk_long org.omg.CORBA.TCKind.tk_float org.omg.CORBA.TCKind.tk_stringand others.
req.set_return_type( longsHelper.type() );
req.invoke();
res = req.result().value(); System.out.println( "Returned: " + res.extract_boolean() );Other versions of extract exist:
extract_boolean() extract_long() extract_float() extract_string()and others.
long[] values = longsHelper.extract( res );