// //////////////////////////////////////////////////////// // Lecture on the CORBA Component Model, summer term 2003 // Assignment 3, Stephan Brumme, 702544 // // CORBA client that calls a remote "reverse" operation // using the naming service // // save and display IOR #include using namespace std; #include "Helper.h" // IDL compiler generated a stub #include "Aufgabe2.h" using namespace Aufgabe2; // CORBA's naming service #include int main(int argc, char* argv[]) { try { // initialize CORBA CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); ////////////////////////////////////// // Connect to Naming Service cout << "Resolve Naming Service ..." << endl; // resolve naming service CORBA::Object_var namingService = orb->resolve_initial_references("NameService"); // not found ? CorbaAssert(namingService, "Couldn't locate the Naming Service."); // get the naming context CosNaming::NamingContext_var namingContext = CosNaming::NamingContext::_narrow(namingService); // not found ? CorbaAssert(namingContext, "Couldn't locate the Naming Service."); // my Windows(R)(TM)(C) login name: "Stephan.Brumme" CosNaming::Name name; name.length(1); name[0].id = CORBA::string_dup("Stephan.Brumme"); name[0].kind = CORBA::string_dup("CCM"); // create and cast the remote object CORBA::Object_var obj = namingContext->resolve(name); CorbaAssert(obj, "Invalid object."); Server_var remote = Server::_narrow(obj); CorbaAssert(remote, "Invalid object."); // invoke the "reverse" operation std::cout << remote->reverse("Corba Component Model") << std::endl; } catch (CORBA::Exception& e) { CorbaError("Corba failed to run properly."); } return 0; }