1 #include "orbsvcs/CosNamingC.h"
2 #include "MessengerC.h"
4 int ACE_TMAIN(int argc
, ACE_TCHAR
* argv
[])
9 CORBA::ORB_var orb
= CORBA::ORB_init(argc
, argv
);
11 CORBA::Object_var rootObj
=
12 orb
->resolve_initial_references("NameService");
14 CosNaming::NamingContext_var rootContext
=
15 CosNaming::NamingContext::_narrow(rootObj
.in());
19 name
[0].id
= CORBA::string_dup ("MessengerService");
21 CORBA::Object_var messengerObj
= rootContext
->resolve(name
);
23 if (CORBA::is_nil(messengerObj
.in())) {
24 std::cerr
<< "Nil Messenger reference" << std::endl
;
29 Messenger_var messenger
= Messenger::_narrow(messengerObj
.in());
30 if (CORBA::is_nil(messenger
.in ())) {
31 std::cerr
<< "Argument is not a Messenger reference" << std::endl
;
35 CORBA::String_var message
=
36 CORBA::string_dup("Where can I get TAO?");
37 messenger
->send_message ("person@company.com",
38 "OCI's Distribution of TAO",
41 message
= CORBA::string_dup("I need TAO now.");
42 messenger
->send_message ("person@company.com",
43 "OCI's Distribution of TAO",
47 catch(const CORBA::Exception
& ex
) {
48 std::cerr
<< "Caught a CORBA exception: " << ex
<< std::endl
;
52 std::cout
<< "MessengerClient: success" << std::endl
;