Show TOC Start of Content Area

Process documentation Developing RMI-IIOP Applications with CORBA Clients  Locate the document in its SAP Library structure

Purpose

To develop an RMI-IIOP application with the CORBA client, you must also define a remote interface and then implement it. The major difference in developing RMI-IIOP applications with Java remote clients is that the stub generation is based on the IDL representation in your remote interface. Refer to the examples below to see how you do this.

Process Flow

The description of this process is also based on the Account remote interface that we introduced in Developing RMI-P4 Applications.

...

       1.      Define the remote interface and implement it as described in Defining a Remote Interface and Implementing the Remote Interface.

       2.      Generate the IDL representation of the Account interface using the standard Java rmic utility with the –idl option.

The IDL is necessary so that the remote object can interoperate with the CORBA client that is written in a programming language other than Java. The IDL generation by the Java remote interface is defined by the Java-to-IDL mapping specification of the Object Management Group (OMG).

       3.      Compile the generated IDL file using an IDL compiler to create the stub classes that are specific for your CORBA client. The IDL compiler is specific for the client ORB implementation and must be provided by the ORB vendor.

       4.      Develop the CORBA client.

Here is a code fragment of a C++ client that looks up an enterprise bean:

Syntax

   cout << "Getting name service reference....." << endl;

   CORBA::Object_var obj = orb -> resolve_initial_references("NameService");

   cout << obj << endl;

   // Obtain the naming context

   cout << "Narrowing reference to naming context......." << endl;

   CosNaming::NamingContext_var context;

   try{

      context = CosNaming::NamingContext::_narrow(obj);

   }catch(const CORBA::Exception& ex){

      cout << ex._to_string()<< endl;

      return 0;

   }

   cout << "Narrow successfull!" <<endl;

 

   CosNaming::Name name;

   name.length(2);

   name[0].id = CORBA::string_dup("HelloApp");

   name[0].kind = CORBA::string_dup("");

   name[1].id = CORBA::string_dup("HelloBean");

   name[1].kind = CORBA::string_dup("");

 

   // Resolve and narrow the object to RMI object

   cout << "Resolving the name....." << endl;

   CORBA::Object_var object;

   try{

      object = context -> resolve(name);

   }catch(const CORBA::Exception& ex){

      cout << ex._to_string() << endl;

      return 0;

   }

   cout << "Resolving the name successfull!" << endl;

 

   CORBA::String_var s = orb -> object_to_string(object);

   cout << "Object to string gets: " << s << endl;

  

   cout << "Narrowing to Hello object....." << endl;

   ::test::HelloHome_var helloHome = test::HelloHome::_narrow(object);

  

   if(CORBA::is_nil(helloHome)) {

      cout << "Can't narrow the object to hello!" << endl;

   }

   else {

      // create an instance of the Hello bean

      test::Hello_var hello = helloHome -> create();

      // call the sayHello() method of the bean

      CORBA::WStringValue* msg = hello -> sayHello();

   }

      cout << endl << "Program stopped" << endl;

      return 0;

}

 

 

End of Content Area