3.6 Step 4: Write the CORBA Client Application

The Oracle Tuxedo software supports the following types of CORBA client applications:

  • CORBA C++

The steps for creating CORBA client applications are as follows:

  1. Initialize the ORB.
  2. Use the Bootstrap object or the CORBA INS bootstrapping mechanism to establish communication with the Oracle Tuxedo domain.
  3. Resolve initial references to the FactoryFinder environmental object.
  4. Use a factory to get an object reference for the desired CORBA object.
  5. Invoke methods on the CORBA object.

The CORBA client development steps are illustrated in the following listing which include code from the Simpapp sample application. In the Simpapp sample application, the CORBA client application uses a factory to get an object reference to the Simple object and then invokes the to_upper() and to_lower() methods on the Simple object.

Here is a code snippet that illustrates the CORBA Client Application from the Simpapp Sample Application.

int main(int argc, char * argv[]) {
        try {
                // Initialize the ORB
                CORBA::ORB_var var_orb = CORBA::ORB_init(argc, argv, "");
                // Create the Bootstrap object
                Tobj_Bootstrap bootstrap(var_orb.in(), "");
                // Use the Bootstrap object to find the FactoryFinder
                CORBA::Object_var var_factory_finder_oref =
                        bootstrap.resolve_initial_references("FactoryFinder");
                // Narrow the FactoryFinder
                Tobj::FactoryFinder_var var_factory_finder_reference =
                        Tobj::FactoryFinder::_narrow(var_factory_finder_oref.in());
                // Use the factory finder to find the Simple factory
                CORBA::Object_var var_simple_factory_oref =
                        var_factory_finder_reference - > find_one_factory_by_id(
                                _tc_SimpleFactory - > id()
                        );
                // Narrow the Simple factory
                SimpleFactory_var var_simple_factory_reference =
                        SimpleFactory::_narrow(
                                var_simple_factory_oref.in());
                // Find the Simple object
                Simple_var var_simple =
                        var_simple_factory_reference - > find_simple();
                // Get a string from the user
                cout << "String?";
                char mixed[256];
                cin >> mixed;
                // Convert the string to upper case :
                CORBA::String_var var_upper = CORBA::string_dup(mixed);
                var_simple - > to_upper(var_upper.inout());
                cout << var_upper.in() << endl;
                // Convert the string to lower case
                CORBA::String_var var_lower = var_simple - > to_lower(mixed);
                cout << var_lower.in() << endl;
                return 0;
        }
}