Creating the CORBA client main code (client.cpp)

Why and when to perform this task

Use this task to create the main code for a CORBA client, to locate a servant object hosted by a CORBA server, and to call methods on the server object. The client's main() function performs the following tasks:

  1. Initializes the client environment
  2. Gets a pointer to the root naming context
  3. Accesses the servant object
  4. Calls methods on the servant object
  5. Stops the client and releases resources used

Steps for this task

  1. Create a source file, client.cpp, where client is the name of the client program.
  2. Edit the client source file, client.cpp, to add appropriate code to implement the client. To do this, complete the following steps:
    1. Add the necessary include statements, as described in Adding include statements.
    2. Add the main() function in the following form:
      main(int argc, char *argv[])
      {
        int rc;
        ::CORBA::Object_ptr objPtr;
        ::CosNaming::NamingContext_var rootNameContext = NULL;
        Servant_var liptr = NULL;
      
        exit( 0 );
      }
       
  3. Add code to initialize the client environment as described in Adding code to initialize the client environment.
  4. Add code to get a pointer to the root naming context as described in Getting a pointer to the root naming context.
  5. Add code to access the servant object that has already been created by the server as described in Adding code to access the servant object.
  6. Add code to call methods on the servant object as described in Adding code to call methods on the servant object.
  7. Add code to shutdown the client and release resources used as described in Adding code to shut down the client and release resources used.

Related tasks
Developing a CORBA C++ client



Searchable topic ID:   tcor_pgmc1
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/corba/tasks/tcor_pgmc1.html

Library | Support | Terms of Use | Feedback