2 #include "orbsvcs/CosNamingC.h"
3 #include "ace/Get_Opt.h"
7 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
11 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
13 CORBA::Object_var tmp
=
14 orb
->string_to_object ("corbaloc:iiop:1.2@localhost:9931/NameService");
16 CosNaming::NamingContext_var root
=
17 CosNaming::NamingContext::_narrow (tmp
.in ());
19 if (CORBA::is_nil (root
.in ()))
21 ACE_ERROR_RETURN ((LM_DEBUG
,
22 ACE_TEXT ("Nil NamingService reference\n")),
27 ACE_TEXT ("**** Narrowed root NamingContext\n")));
31 name
[0].id
= CORBA::string_dup ("nsB");
32 name
[1].id
= CORBA::string_dup ("example");
33 name
[2].id
= CORBA::string_dup ("Hello");
37 tmp
= root
->resolve (name
);
39 ACE_TEXT ("**** Resolved #nsB/example/Hello\n")));
41 Test::Hello_var hello
=
42 Test::Hello::_narrow (tmp
.in ());
44 if (CORBA::is_nil (hello
.in ()))
46 ACE_ERROR_RETURN ((LM_DEBUG
,
47 ACE_TEXT ("Nil Test::Hello reference\n")),
51 CORBA::String_var the_string
= hello
->get_string ();
54 ACE_TEXT ("(%P|%t) - string returned <%C>\n"),
59 catch (const CosNaming::NamingContext::CannotProceed
&)
62 ACE_TEXT ("Caught correct exception\n")));
68 catch (const CORBA::Exception
& ex
)
70 ex
._tao_print_exception (ACE_TEXT ("Exception caught:"));