1 #include "ace/Log_Msg.h"
4 #include "ace/SString.h"
5 #include "ace/Get_Opt.h"
7 const ACE_TCHAR
*ior
= ACE_TEXT ("file://server.ior");
8 const ACE_TCHAR
*cert_file
= ACE_TEXT ("cacert.pem");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
16 while ((c
= get_opts ()) != -1)
20 ior
= get_opts
.opt_arg ();
25 ACE_ERROR_RETURN ((LM_ERROR
,
32 // Indicates successful parsing of the command line
37 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
41 ACE_TString
env (ACE_TEXT ("SSL_CERT_FILE="));
43 ACE_OS::putenv ( ACE_TEXT_ALWAYS_CHAR(env
.c_str ()));
49 CORBA::ORB_init (argc
, argv
);
51 if (parse_args (argc
, argv
) != 0)
57 CORBA::Object_var obj
=
58 orb
->resolve_initial_references ("RootPOA");
60 PortableServer::POA_var poa
=
61 PortableServer::POA::_narrow (obj
.in ());
64 // Get a reference to the server.
66 obj
= orb
->string_to_object (ior
);
68 if (CORBA::is_nil (obj
.in ()))
70 ACE_ERROR_RETURN ((LM_ERROR
,
71 ACE_TEXT ("(%P) orb->string_to_object ")
72 ACE_TEXT ("(\"file://server.ior\") failed.\n")),
77 // Downcast the IOR to the appropriate object type.
79 server_var server_obj
=
80 server::_narrow (obj
.in ());
82 if (CORBA::is_nil (server_obj
.in ()))
84 ACE_ERROR_RETURN ((LM_ERROR
,
85 ACE_TEXT ("(%P) server::_narrow(obj) failed.\n")),
90 // Create and activate the client.
92 client_i
*servant
= 0;
93 ACE_NEW_RETURN (servant
,
94 client_i (server_obj
.in ()),
96 PortableServer::ServantBase_var theClient
= servant
;
98 client_var client_ref
= servant
->_this ();
101 // Activate the POA manager.
103 PortableServer::POAManager_var mgr
=
104 poa
->the_POAManager ();
109 // Set the server's callback and invoke the test request.
111 server_obj
->set_client (client_ref
.in ());
113 server_obj
->test_request ("first secure callback to client");
116 // Repeat the callback test.
118 server_obj
->set_client (client_ref
.in ());
119 server_obj
->test_request ("second secure callback to client");
121 server_obj
->shutdown ();
123 poa
->destroy (true, true);
127 catch (const CORBA::Exception
& ex
)
129 ex
._tao_print_exception (ACE_TEXT ("Caught exception\n"));