I am trying (for the first time) to do a CORBA call in c++ (TAO, VC6
on win XP)
I have this IDL, notice, that exec has 3 parameters, the thirs is used
for a list of return values from the corba server.
module cna {
module mmsc {
struct BridgeParam {
string paramName;
string paramValue;
};
struct MMSCErrorDetails {
long errorCode;
string errorMessage;
};
exception MMSCException {
MMSCErrorDetails errorDetails;
};
typedef sequence< BridgeParam > BridgeParamList;
interface MMSCBridge {
void exec (in string requestName,
in BridgeParamList inParams,
out BridgeParamList outParams)
raises (MMSCException);
};
};
};
TAO compiles this to :
virtual void exec (
const char * requestName,
const ::cna::mmsc::CNAIdentification & cnaIdentification,
const ::cna::mmsc::BridgeParamList & inParams,
::cna::mmsc::BridgeParamList_out outParams
)
with
typedef
TAO_Seq_Out_T<
BridgeParamList,
BridgeParamList_var,
BridgeParam
>
BridgeParamList_out;
class BridgeParamList
: public
TAO_Unbounded_Sequence<
BridgeParam
>
{
struct BridgeParam
{
typedef BridgeParam_var _var_type;
static void _tao_any_destructor (void *);
TAO_String_Manager paramName;
TAO_String_Manager paramValue;
};
Now, when I want to call exec I must supply a variable for the third
parameter, that I wanted to name outPar. I tried like this:
::cna::mmsc::BridgeParam o1;
o1.paramName=CORBA::string_dup("USER_ID");
o1.paramValue=CORBA::string_dup("wna");
::cna::mmsc::BridgeParamList outList(2);
outList[0]=o1;
::cna::mmsc::BridgeParamList_var outList_var(&outList);
::cna::mmsc::BridgeParamList_out outPar(outList_var);
I that last line I get an exception! Somehow that is not the way its
done. Any tips, ideas of what I am doing wrong? Sorry, no, I cant
change the way exec is called, I have no controll over the source for
it. So the parameters have to stay the way there are, I cant just make
exec return a list as a return value.
TIA - klaus
There is no need (in the client) to initialize an out parameter. You can
just pass the _var parameter like this:
::cna::mmsc::BridgeParamList_var outList_var;
bridge->exec("req", inParams, outList_var);
Check the Henning & Vinoski book
(http://cseng.aw.com/book/0,3828,0201379279,00.html) for details or its
sample chapter about the C++ mapping
(http://www.awl.com/cseng/titles/0-201-37927-9/cpp_mapping.pdf).
Cheers
Stelios
--
Stelios G. Sfakianakis | eHealth Laboratory
Voice: +30-2810-391650 | Institute of Computer Science
PGP Key ID: 0x5F30AAC2 | FORTH, http://www.ics.forth.gr/