18 October 2005

CORBA powered by .Net and C#

What is Common Object Request Broker Architecture?
CORBA is a distributed system like Web Services or EJBs. In fact, CORBA applications are composed of objects which provide functionalities and datas. To create a CORBA object, you just have to define an interface (OMG Interface Description Language) which is the description of the object itself (methods, ...).
The IDL is very useful for clients that invoke a CORBA object because this interface contains all the needed information about the object.

In fact, you have the ORB (Object Request Broker) which is a bus (objects server) that contains the implementation of the CORBA objects. The clients can invoke the objects and get their references thanks to the IIOP protocol. After getting the object reference, the client can call its methods...
For more information about the CORBA specifications, please see the following links:
- http://www.corba.org/
- http://www.omg.org/gettingstarted/corbafaq.htm
- http://www.omg.org/
- http://www.cetus-links.org/oo_corba.html

Can I write a CORBA application in C# .Net?
Yes of course, you can make it easily.
First, you just have to download a middleware to compile an IDL file of your object and get a C# (.cs) file back.

This example shows to operation in using Borland Janeva but you can use others middlewares like MiddCor, J-Integra Espresso or also Remoting Corba...

After you have to install Janeva (refer the Janeva Installation Guide), if Visual Studio doesn't add the "Borland.Janeva.Runtime" dll and "Borland.Janeva.Services" dll to your project references, you have to add them by yourself.
Now you can start to build your IDL and as soon as it's done, you just have to compile it.
In command line: idl2cs –servant ObjetExemple.idl
In Visual Studio: see the Janeva Guide (pdf)
The compilator will generate a CSharp file called in our case ObjetExemple.cs.
The following step is the servant, class that I've called ObjetExempleImp which have to implement the ObjetExemplePOA interface (located in the ObjetExemple.cs file).
class ObjetExemplerImpl: ObjetExemplePOA
{
   …
}


You can find the implementation of the server which instanciates the servant and registers it in the ORB. I use VisiBroker 4 from Borland as objects server (ORB). To test it, I've also added a little client which calls the distant object methods.
As you see, I use VisiBroker 4. So yoo must install it before and run its naming service in command line (in this case I use the port 1412 as listening port):
nameserv NameService -J-Dvbroker.se.iiop_tp.scm.iiop_tp.listener.port=1412
Now launch the server:
Serveur -ORBInitRef NameService=corbaloc:iiop:1.2@MachineName:1412/NameService
and launch the client:
Client -ORBInitRef NameService=corbaloc:iiop:1.2@MachineName :1412/NameService
Be sure to have well install Janeva and copy the evaluation license file in its folder (you received it by mail when downloading Janeva). The evaluation license only work if the client and the server are running on the same machine.

Donwload the project sources here

Jay

0 Comments:

Post a Comment

<< Home