CORBA - Calling CORBA using IOR

"The Common Object Requesting Broker Architecture (CORBA) is a standard defined by the Object Management Group (OMG) that enables software components written in multiple computer languages and running on multiple computers to work together." - WikiPedia(

For objects to be used across a network, a client/server relationship must be established. The middleware that makes this happen is called the Object Request Broker (ORB). 
It is the ORB's job to:

  • intercept a call from the client
  • find the correct object
  • pass it the parameters
  • invoke its method
  • return the results to the client

Clients issue a request on a CORBA object using an object reference. Client side CORBA objects are generated by IDL compiler

The IDL compiler for Java programming language generates client-side stubs, which represent the CORBA object locally in the Java programming language. 

IDL interfaces are programming language neutral.

The command "idltojava Stock.idl" generates the files listed below:
The IDL interface represented as a Java interface
Implements the type operations for the interface
Used for out and inout parameters
Implements a local object representing the remote CORBA object. This object forwards all requests to the remote object. The client does not use this class directly.
So, we know ORB and IDL interface, One more thing which is very important is "IOR".
IOR(Interoperable Object Reference) is the contact details that a client application uses to communicate with a CORBA object. 
Remember, each CORBA object has got identity which is unique within a server process. IOR provides the means to obtain an intial reference to an object, be it naming service, transaction service, or customized CORBA servant. 
ORB's publish object references using IOR. 
Most Important, An IOR contains the information required for a client ORB to connect to a CORBA object. 
An IOR contains the folowing information: IIOP Version, Host, Port, Key, and Component. Host is TCP/IP address of the ORB's host machine. for example:
object_to_string(org.omg.CORBA.Object o) converts the given CORBA object reference to a stringified IOR. 
string_to_object(String ior) converts a stringified IOR produced by object_to_string(.) back to CORBA object reference. 
Both string_to_object(..) and object_to_string(..) are defined in the ORB class. 
So, If we writing a client program, we need an ORB, IOR, Stubs(generated by IDLJ compiler), etc. 
We must understand few more concepts before we lok at an example.
NamingContext - NamingContext is a object that contains a set of name bindings in which each name is unique. 

A helper class is generated after compilig the idl file. 
The id() operation defined in the helper class returns a repository id for the interface. The repository id is a string representing the interface. 

NameComponent - Many of the operations defined on a naming context take names as parameters. Names have structure. A name is an ordered sequence of components.A name component consists of two attributes: the identifier attribute and the kind attribute. Both the identifier attribute and the kind attribute are represented as IDL strings.
resolve( ) method in the NamingContext takes NameComponent as parameter. 
resolve( ) operation is the process of retrieving the object bound t a name in the context. 

NameComponent(String id, String _kind)

Now, we look at the sample code which uses CORBA object for performing operation. 
/* This sample code is used for getting Service Manager. There is a Server to which we gave to connect and get the servce manager object. Idea is to get a Naming Context which is a CORBA object, get server object, authenticate, and then get service manager.  */
// Sample Code Start
Step 1.
              org.omg.CORBA.ORB myOrb = org.omg.CORBA.ORB.init(args, null);
Step 2. 
             Context ctx = new InitialContext();
             org.omg.CORBA.Object rootObj = null;
             NamingContext root = null;
             rootObj = myOrb.string_to_object(nameServiceString); 
             root = NamingContextHelper.narrow(rootObj);
Step 3. 
              NameComponent nc[] =              { new NameComponent(, "") };            
            org.omg.CORBA.Object authServerObj = root.resolve(nc);
            ICorbaSMAF_Authentication authServer =            ICorbaSMAF_AuthenticationHelper.narrow(authServerObj);
Step 4.    
              String smaf_ManagerFactoryIOR = authServer.authenticate(userid,password);
Step 5. 
               iCorbaSMAF_ManagerFactory =  ICorbaSMAF_ManagerFactoryHelper.narrow(myOrb.string_to_object(smaf_ManagerFactoryIOR));
Step 6.  
               String corbaSmServiceManagerIOR = "";
            corbaSmServiceManagerIOR = iCorbaSMAF_ManagerFactory.getServiceManager();

theCorbaSmServiceManager = ICorbaSmServiceManagerHelper.narrow(myOrb.string_to_object(corbaSmServiceManagerIOR));

// Sample Code Ends

nameServiceString - is an IOR for the NamingContext. And name of the Server is bound to this naming context.  

Step 1, is to instantiate a client ORB. 

Step 2, is to get the CORBA object from the IOR. CORBA object is a NamingContext. Remember, object returned by the string_to_object(String ior) is of CORBA Object type, We must use Narrow( ) to get the more specific reference. 

Step 3, is Contacting the authentication server
We know that, Authentication Server is a object bound to the NamingContext. NamingContext is a CORBA object which we got in the Step 2. 
Getting the object bound to the namingcontext is a two step process. 
First instantiate a NameComponent passing the id, and kind.
Secondly, pass this NameComponent to the NamingContext' resolve method.
remember the syntax for the rsolve method is:
public object resolve(NameComponent [ ] n) throws NotFound. cannotProceed, InvalidName method returns the repository id of ICorbaSMAF_Authentication, this repository id is the symbolic name of  Authentication server. We instantiate NameComponent using this id and pass Namecomponent to NamingContext's resolve method. The resolve method returns us a authserver object. 

So, Till now we had a IOR(serviceName), we got object corresponding to the IOR, and the object was NamingContext. We got the authentication server object bound to this naming context. 

Step 4, is authenticating the client, passing the username and password to authenticate method defined the authserver object. 
The suthenticate method returns us a String. Now this String is also a IOR. This IOR is generated for the client(i.e. our program) and it contains user credentials. 
We are going to use this IOR, to establish connection to ManagerFactory and from thyere we get ServiceManager.(Step 5 & Step 6)

Step 5, is used for value for a reference to remote object. We have the helper class, for the desired CORBA object. We would call narrow method to get the object on the Helper class. To tht narrow method we pass the object reference. 
smaf_ManagerFactoryIOR is a client dedicated IOR, we convert it to object refernce using the string_to_object method and pass this reference to narrow method to get the value for this object. 

Step 6, is getting the IOR for the Service Manager.

Now, when we get the Service manager, further we would get object reference for this IOR, and call required methods on the reference CORBA bject.


Popular Posts