4 int main(int argc, char** argv)
7 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
8 CORBA::Object_var obj = orb->string_to_object("corbaname:rir:#test.my_context/Echo.Object");
9 eo::Echo_var echoref = eo::Echo::_narrow(obj);
10 if( CORBA::is_nil(echoref) ) {
11 std::cerr << "Can't narrow reference to type Echo (or it was nil)." << std::endl;
15 CORBA::String_var src = (const char*) "Hello!";
16 CORBA::String_var dest = echoref->echoString(src);
17 std::cerr << "I said, \"" << (char*)src << "\"." << std::endl
18 << "The Echo object replied, \"" << (char*)dest <<"\"." << std::endl;
20 CORBA::Object_var ob = orb->string_to_object("corbaname:rir:#test.my_context/D.Object");
21 eo::D_var Dref = eo::D::_narrow(ob);
22 if( CORBA::is_nil(Dref) ) {
23 std::cerr << "Can't narrow reference to type D (or it was nil)." << std::endl;
29 echoref->echoD(Dref,dout);
30 std::cerr << dout->echoLong2(10) << std::endl;
33 echoref->echoD(dout,ddout);
34 std::cerr << dout->echoLong2(10) << std::endl;
36 CORBA::Object_var oob = orb->string_to_object("corbaname:rir:#test.my_context/Obj.Object");
37 eo::Obj_var Objref = eo::Obj::_narrow(oob);
40 echoref->echoObj2(Objref,Objout);
41 std::cerr << Objout->echoLong(10) << std::endl;
43 CORBA::Object_var cob = orb->string_to_object("corbaname:rir:#test.my_context/C.Object");
44 eo::C_var Cref = eo::C::_narrow(cob);
46 echoref->echoC(Cref,Cout);
48 echoref->echoObj2(Cref,Objout);
49 //echoref->echoC(Cref,Objout); compilation impossible
50 //echoref->echoObj2(Cref,Cout); compilation impossible
51 //echoref->echoC(Objref,Cout); compilation impossible
55 catch(CORBA::COMM_FAILURE& ex) {
56 std::cerr << "Caught system exception COMM_FAILURE -- unable to contact the "
57 << "object." << std::endl;
59 catch(CORBA::SystemException&) {
60 std::cerr << "Caught a CORBA::SystemException." << std::endl;
62 catch(CORBA::Exception&) {
63 std::cerr << "Caught CORBA::Exception." << std::endl;
65 catch(omniORB::fatalException& fe) {
66 std::cerr << "Caught omniORB::fatalException:" << std::endl;
67 std::cerr << " file: " << fe.file() << std::endl;
68 std::cerr << " line: " << fe.line() << std::endl;
69 std::cerr << " mesg: " << fe.errmsg() << std::endl;
72 std::cerr << "Caught unknown exception." << std::endl;