[Previous] [Contents] [Next] [IONA Technologies]


Chapter 9
ORB Interoperability


Contents

9.1 Overview of GIOP
9.1.1 Coding
9.1.2 Message Formats
9.1.3 Internet Inter-ORB Protocol (IIOP)
9.2 IIOP in OrbixWeb
9.2.1 Example using IIOP in a Platform-Independent Application
9.2.2 Using IIOP and Binding from an OrbixWeb Client
9.2.3 Configuring an IIOP Port Number for an OrbixWeb Server
9.2.4 Using IIOP with Type any



The goal of ORB Interoperability is to allow communication between independent implementations of the CORBA standard. Specifically, ORB interoperability allows a client of one ORB to invoke operations on an object in a different ORB via an agreed protocol. Thus, invocations between client and server objects are independent of whether they are on the same or different ORBs.

The OMG agreed protocol for ORB interoperability is called the General Inter-ORB Protocol (GIOP). GIOP defines the on-the-wire data representation and message formats; it also makes general assumptions about the nature of the transport layer–in particular, that it is connection-oriented. A goal of the GIOP specification is to allow different ORB implementations to communicate without restricting ORB implementation flexibility.

The OMG defines a specialisation of GIOP that uses TCP/IP as the transport layer. This specialisation is called the Internet Inter-ORB Protocol (IIOP). Specialised protocols for different transports (for example, OSI, Netware, IPX) or for new features (such as security) are expected to be defined by the OMG in due course.

There are many reasons why interoperability between the products of different ORB vendors is desirable. The core CORBA specification defines a standard for making invocations on an object via an ORB. A natural extension of this standard is that conforming implementations should allow invocations on objects from other conforming implementations. Within an organisation different ORBs may coexist reflecting separate development effort or different ORB requirements by different parts of the organisation and at some point, these ORBs may need to communicate.

We give an overview of the GIOP and IIOP specifications in section 9.1. Section 9.2 shows an example of using IIOP in OrbixWeb.

9.1 Overview of GIOP

This section provides an overview of the elements of the GIOP specification.1 It is provided primarily as background information.

9.1.1 Coding

The GIOP defines a transfer syntax known as Common Data Representation (CDR). CDR defines a coding for all IDL data types: basic types, structured types (including exceptions), object references and pseudo-objects such as TypeCodes.

All basic types are aligned on their natural boundaries. The architecture of the message sender determines whether the byte ordering is big-endian or little-endian; it is then the responsibility of the receiver to decode the message according to the byte ordering. Thus machines with common byte ordering may exchange messages without unnecessary byte swapping.

9.1.2 Message Formats

Seven message types are defined by GIOP. A common message header is defined for all messages which includes the message size, a version number indicating the version of GIOP being used, the byte ordering and the message type. Messages are exchanged between clients and servers. In this context, a client is an agent that opens connections and originates requests. A server is an agent that accepts connections and receives requests. The type of a message is one of the following:

How these messages are used by an implementation of GIOP is transparent to the application. For example, a particular implementation may respond to a LOCATE_FORWARD status in a Reply message by transparently reissuing the call. Similarly, use of the LocateRequest message is an optional optimization.

9.1.3 Internet Inter-ORB Protocol (IIOP)

The mapping of GIOP message transfer to TCP/IP connections is called the Internet Inter-ORB Protocol (IIOP).

An object accessible via IIOP is identified by an interoperable object reference (IOR). Since the format of normal object reference is not prescribed by the OMG, the format of an IOR includes an ORB's internal object reference as well as an internet host address and a port number. An IOR is managed internally by the interoperating ORBs–it is not necessary for an application programmer to know the structure of an IOR.

9.2 IIOP in OrbixWeb

OrbixWeb supports the native Orbix protocol and IIOP as alternative protocols. A programmer may indicate during compilation of an IDL definition which protocol should be used in the generated Java code for that definition. A client program can then make invocations on this definition and OrbixWeb automatically determines which protocol is required. At this point, the chosen protocol is largely transparent at the application level.

As described in Chapter 7, "Publishing Object References in Servers", there are several ways in which a server can publish an object reference or IOR for retrieval by clients. Again, in this respect the protocol used does not affect the options available to application programmers.

However, IIOP has two important advantage over the Orbix protocol: the first is simply interoperability with other ORBs, and the second is the availability of servers which have no platform-specific requirements–which is especially important in the Java domain.

Chapter 11, "Registration and Activation of Servers" describes how OrbixWeb servers can be run in a distributed system and their requirements in this context. An important factor which must be taken into account is that all servers which communicate using the Orbix protocol require an OrbixWeb daemon to run on the server host. This limits these servers to platforms where an OrbixWeb daemon is available. However, using IIOP client and server applications can be designed which have no external dependencies and are platform-independent.

For example, the following application pair would be interoperable across ORBs and platform-independent:

The methods processEvents() and processNextEvent() can be used to accept incoming OrbixWeb requests in a similar manner to impl_is_ready(), but these methods do not require the initialisation of an OrbixWeb server name.

9.2.1 Example using IIOP in a Platform-Independent Application

This section illustrates the use of IIOP in OrbixWeb to create an interoperable application which does not rely on the availability of an OrbixWeb daemon process. The application developed here consists of a client and server as described in the example above. That is, the server creates an IOR which it publishes using the Naming Service and then invokes processEvents() to handle client invocations on that IOR. The client simply retrieves the IOR using the Naming Service and invokes operations on the server object.

The example is based on the following IDL interface representing a two dimensional grid.

Compiling the IDL Definition

To indicate that the marhsalling protocol uses IIOP, the IDL definitions could be compiled using the -m switch as follows:

However, this is the default setting, so it is not necessary to specify the -m switch in order to use IIOP.

Alternative values for the -m switch are orbixOnly, which generates support for the Orbix protocol, and interOp, which allows both protocols to be used. IDL definitions which are not compiled with the setting orbixOnly or the setting interOp cannot be accessed using the native Orbix protocol.

Programming the Server

The server code is shown below. Note that this assumes that an implementation of the Naming Service, for example OrbixNames, is available and correctly installed. Following the convention used elsewhere in this guide, we assume that class GridImplementation implements interface Grid.

This server instantiates a TIE object for interface Grid. By default, OrbixWeb automatically identifies this object using an IOR. The server then resolves the initial context in the Naming Service and associates the compound name objects.math.grid with the IOR, in the manner described in Chapter 7, "Publishing Object References in Servers". Finally, the server enters an OrbixWeb event processing loop by calling processEvents().

Programming the Client

This client program resolves the name objects.math.grid to locate the object reference published by the server using the Naming Service. The interoperable object reference retrieved from the Naming Service must be narrowed to an object reference of the appropriate interface before operations can be invoked on it in the normal way.

The source code for the client is as follows:

9.2.2 Using IIOP and Binding from an OrbixWeb Client

As illustrated throughout this guide, it is possible to register an OrbixWeb IIOP server in the Implementation Repository. In this case, the OrbixWeb daemon becomes responsible for locating the server IOR on a client's initial invocation and has the opportunity to launch a server process, if required. This has the drawback of introducing a dependency on an OrbixWeb daemon at the server host, but allows the server to take advantage of the OrbixWeb automatic launch facilities.

The mechanism required to register a server in the Implementation Repository is independent of the server protocol. However, an additional registration option is available to servers which use IIOP, as described in "Configuring an IIOP Port Number for an OrbixWeb Server".

In order to use _bind() to resolve IORs in an OrbixWeb client, the server must be registered in the Implementation Repository (unless the OrbixWeb daemon is run with the -u switch) and the server must call impl_is_ready() to initialise its server name. In addition, the client must be configured to use IIOP in OrbixWeb communications (which is the default case).

As described in Chapter 3, "OrbixWeb Configuration" of the OrbixWeb Reference Guide, the OrbixWeb class Configure allows a programmer to specify, during compilation, several configuration variables including the default protocol to be used when the client binds to a server object. In the context of using IIOP in a _bind() call, this class allows the following values to be modified:

This default assignment for _CORBA.IT_BIND_USING_IIOP allows calls to _bind() which use IIOP. This assignment may be changed to the following:

In this case, calls to _bind() can only use the Orbix protocol.

The variable _CORBA.IT_ORBIXD_IIOP_PORT specifies the port number on which the OrbixWeb daemon listens for incoming IIOP requests. When calling _bind() using IIOP, it is important that the client's setting for this variable matches the OrbixWeb daemon IT_IIOP_PORT value, as set in the OrbixWeb configuration file, Orbix.cfg.

Note that class Configure must be recompiled if a configuration value is modified. See Chapter 3, "OrbixWeb Configuration" of the OrbixWeb Reference Guide for further details of configuration issues.

Specifying a Communications Port for the OrbixWeb Daemon

It is important to note that the OrbixWeb daemon process listens for incoming OrbixWeb events on two communications channels: one for Orbix protocol messages, the other for IIOP messages. If a client wishes to invoke _bind() using IIOP, then it should ensure that it communicates with the OrbixWeb daemon using the daemon IIOP port number and not the Orbix protocol port. For details, see Chapter 3, "OrbixWeb Configuration" of the OrbixWeb Reference Guide.

9.2.3 Configuring an IIOP Port Number for an OrbixWeb Server

Using IIOP, an OrbixWeb server must listen for client connection requests on a fixed TCP/IP port. The port number for each server is assigned by OrbixWeb on start-up.

Unfortunately, the port number assigned to a server subsequently becomes embedded in the contents of any IORs which that server creates. This approach has the disadvantage that a server which exits and is relaunched may no longer be able to recreate objects with IORs which exactly match those created in an earlier process. For this reason, OrbixWeb allows application programmers to select a well-known IIOP port for each server program.

By default, the OrbixWeb daemon will manage a well-known port for a server. This feature can be disabled by setting the static boolean variable _CORBA.IT_IIOP_USE_LOCATOR to false in the server, as follows:

This setting must be applied before any IORs are created in the server.

During registration of a server in the Implementation Repository, a well-known port for a server can be specified using the putit -port switch, for example:

If _CORBA.IT_IIOP_USE_LOCATOR is set to true and a port number has been specified for the server in this manner, then the OrbixWeb daemon will attempt to assign the required IIOP port to the server. If that port is not available, then an attempt to create an IOR in the server will raise a system exception.

If _CORBA.IT_IIOP_USE_LOCATOR is set to false, and a port number has not been specified in a putit command, then the OrbixWeb daemon will assign a default well-known port to the server.

A server which does not depend on the availability of an OrbixWeb daemon process should set _CORBA.IT_IIOP_USE_LOCATOR to false. In this case, an alternative mechanism is required to allow the server to establish a well-known IIOP port number. This can be achieved by altering class Configure before compilation of the server.

Class Configure includes the following variable setting:

A server programmer may edit the setting for the _CORBA.IT_IIOP_LISTEN_PORT variable and then recompile this class. The value of _CORBA.IT_IIOP_LISTEN_PORT can also be reassigned in an OrbixWeb server by simply adding the lines:

This approach is only effective if the new value is assigned before the creation of any IORs in the server. The value of _CORBA.IT_IIOP_LISTEN_PORT has no significance if _CORBA.IT_IIOP_USE_LOCATOR is set to true.

If _CORBA.IT_IIOP_LISTEN_PORT is set to zero, then the server will not be associated with a well-known port number–that is, an IIOP port will be dynamically assigned to the server on start-up.

9.2.4 Using IIOP with Type any

Chapter 18, "Type any" describes the OrbixWeb mapping for IDL type any to Java type Any (defined in package IE.Iona.Orbix2.CORBA). In an OrbixWeb application, it is necessary to specify the protocol which will be used to marshal an any value during creation of the any. For this reason, the Java type Any includes constructors which allow the desired protocol to be configured.

These constructors are defined as follows:

where the variable kind is an integer with one of the following values:

     IE.Iona.Orbix2._CORBA.IT_ORBIX_OR_KIND
    
     IE.Iona.Orbix2._CORBA.IT_INTEROPERABLE_OR_KIND
    

The constant value _CORBA.IT_ORBIX_OR_KIND (defined in package IE.Iona.Orbix2) indicates that the any will be marshalled using the Orbix protocol; the value _CORBA.IT_INTEROPERABLE_OR_KIND indicates that the any will be marshalled using the IIOP protocol.

When OrbixWeb is installed, the default protocol for marshalling of any values is IIOP. In the next subsection, we will describe how this default value may be configured during client compilation.

Configuring the Default Marhsalling Protocol for Type any

The OrbixWeb class Configure allows a programmer to specify, during compilation, the default communications protocol to be used when marshalling anys. In this context, the relevant section of this class is:

In order to specify which protocol should act as the default for type any marshalling, the programmer should do the following:



1 Full details of the ORB Interoperability specification are available from the OMG at OMG Headquarters, 492 Old Connecticut Path, Framingham, MA 01701 USA.

Tel: 508-820 4300
E-mail: pubs@omg.org
WWW:http://www.omg.org



[Roadmap] [Introduction] [GS: Applications] [GS: Applets]
[IDL] [Mapping] [Programming OrbixWeb] [Publishing Objects] [Retrieving Objects] [IIOP]
[Running Clients] [Running Servers] [Exceptions] [Inheritance] [Callbacks] [Contexts]
[API Configuration] [TypeCode] [Any] [DII] [IR] [Filters] [Smart Proxies] [Loaders] [Locators]
[Index]