1 #include "amh_ami_pch.h"
2 #include "ace/Get_Opt.h"
7 const ACE_TCHAR
*ior_file
= ACE_TEXT ("file://middle.ior");
10 parse_args (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
15 while ((c
= get_opts ()) != -1)
19 ior_file
= get_opts
.opt_arg ();
23 ACE_ERROR_RETURN ((LM_ERROR
,
30 // Indicates successful parsing of the command line
34 int ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[])
37 // Initialize the ORB.
38 CORBA::ORB_var orb
= CORBA::ORB_init( argc
, argv
);
40 if (parse_args (argc
, argv
) != 0)
43 // Read and destringify the Asynch_Except_Demo object's IOR.
44 CORBA::Object_var obj
= orb
->string_to_object(ACE_TEXT_ALWAYS_CHAR(ior_file
));
45 if( CORBA::is_nil( obj
.in() ) ) {
46 std::cerr
<< "Could not get middle IOR." << std::endl
;
50 // Narrow the IOR to a Asycnh_Except_Demo object reference.
51 Middle_var mid
= Middle::_narrow( obj
.in() );
52 if( CORBA::is_nil( mid
.in() ) ) {
53 std::cerr
<< "IOR was not an middle object reference." << std::endl
;
57 CORBA::String_var question
=
58 CORBA::string_dup ("How much wood would a woodchuck chuck, if a woodchuck could chuck wood?");
60 std::cout
<< "Question is: " << question
.in() << std::endl
;
63 // trigger the exception via AMI call
64 CORBA::String_var answer
=
65 mid
->get_the_answer (question
.in());
67 std::cout
<< "Answer is: " << answer
.in() << std::endl
;
71 catch(const CORBA::Exception
& ex
) {
72 std::cerr
<< "CORBA exception: " << ex
<< std::endl
;