4 #include "tao/DynamicInterface/Request.h" /* This must come first for
7 #include "ace/Get_Opt.h"
9 #include "ace/Log_Msg.h"
10 #include "DII_ReplyHandler.h"
11 #include "tao/AnyTypeCode/Any.h"
12 #include "tao/PortableServer/POAC.h"
13 #include "tao/PortableServer/POAManagerC.h"
15 const ACE_TCHAR
*ior
= ACE_TEXT("file://server.ior");
20 parse_args (int argc
, ACE_TCHAR
*argv
[])
22 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("xk:"));
25 while ((c
= get_opts ()) != -1)
33 ior
= get_opts
.optarg
;
38 ACE_ERROR_RETURN ((LM_ERROR
,
47 // Indicates successful parsing of the command line
52 do_primary_test (CORBA::Object_var
&server
,
53 Messaging::ReplyHandler_var
&callback
)
57 CORBA::Request_var req
= server
->_request("do_forward");
59 if (CORBA::is_nil (server
.in ()))
62 "Object reference <%s> is nil.\n",
67 ACE_DEBUG((LM_DEBUG
,"Client sending test string\n"));
68 CORBA::String_var test_string
= CORBA::string_dup ("123 look at me");
69 req
->add_in_arg ("text") <<=
70 CORBA::Any::from_string(test_string
.in(),30);
71 req
->sendc(callback
.in());
73 catch (const CORBA::Exception
&ex
)
76 "Client caught exception: %C\n",ex
._name()));
80 int do_shutdown_test (CORBA::Object_var
&server
)
83 "[client] invoking shutdown on the server \n"));
86 CORBA::Request_var req
= server
->_request("shutdown");
89 catch (const CORBA::Exception
& ex
)
91 ex
._tao_print_exception ("Client: exception caught during shutdown - ");
99 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
105 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
107 if (parse_args (argc
, argv
) != 0)
110 ACE_DEBUG ((LM_DEBUG
,"Client using ior source %s\n", ior
));
111 CORBA::Object_var server
= orb
->string_to_object (ior
);
113 CORBA::Object_var obj
= orb
->resolve_initial_references ("RootPOA");
114 PortableServer::POA_var root
=
115 PortableServer::POA::_narrow (obj
.in());
117 PortableServer::POAManager_var pm
= root
->the_POAManager();
119 bool got_reply
= false;
120 Messaging::ReplyHandler_var callback
= new DII_ReplyHandler(got_reply
);
122 do_primary_test (server
,callback
);
124 for (int i
= 0; i
< 100 && !got_reply
; i
++)
126 ACE_Time_Value
t(0,10000);
127 orb
->perform_work(t
);
131 result
= do_shutdown_test (server
);
133 ACE_DEBUG ((LM_DEBUG
,"Shutting down and destrying ORB.\n"));
135 ACE_DEBUG ((LM_DEBUG
,"ORB destroyed\n"));
137 catch (const ::CORBA::Exception
&ex
)
139 ex
._tao_print_exception("ERROR : unexpected CORBA exception caugth :");