RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Connecting CORBA to .NET : Page 4

In this article, you'll see how to build a CORBA server and connect it to C# clients using Borland's Janeva as "glue".


Calling the CORBA Server
After configuring the client application, you can use a button to create an instance of the CORBA DiarySrv object and call the Meeting method as shown in the following button1_Click method.

   private void button1_Click(object sender, 
      System.EventArgs e)
         MyCorbaDiaryServer =
         DiarySrv.DateTime MyDateTime = new 
         MyDateTime.Date = 
         MyDateTime.Time = 
            MyDateTime, Convert.ToInt32(textBox4.Text));
           MessageBox.Show(ex.Reason, "CORBA Exception");
         catch (Exception ex)
           MessageBox.Show(ex.Message, "Error");

See Listing 1 for the full Windows Form class code.

First, you have to call the Bind method, passing the exact name that was specified by the CORBA Server application to create the CORBA Diary Server object (in this case, that code was generated by C++Builder, and is "ICorbaDiaryServerObject"—see the downloadable C++ source files for details).

After binding the CORBA Server object, you can call the Meeting method. But not without retrieving the date and time and construction the special DiarySrv.DateTime object (the custom type defined in the IDL file and implemented by the CORBA server).

Figure 9. C#Builder CORBA Client: The figure shows the main window for the completed CORBA client running.

Listing 1 also contains the definitions for the four Labels and TextBox controls used to allow the enduser to enter the required information for the meeting like the names, date, time, and duration. At runtime, the application looks like Figure 9—complete with sample meeting:

Note that the Duration value is set to 61 minutes in the running sample in Figure 9 only to ensure that the sample throws a CORBA exception on the server side. As soon as you click on the "Make Appointment" button, you'll get a CORBA exception (see Figure 10):

Figure 10. CORBA Exception: A MessageBox display of an exception received by the C#Builder CORBA client.

As long as you limit the value for Duration to 60 minutes or less, you can safely add meetings to the agenda (although the simple CORBA server doesn't actually do anything with them, but that's left as an exercise for the reader).

What you're seeing here is Janeva acting as the so-called Enterprise Application Integration (EAI) layer between the CORBA Server object and the C# Client application. The major benefit of this technology is that you do not have to rewrite or modify your existing CORBA server applications to connect them to .NET applications.

So, now you've seen how to connect a CORBA server application to a C#Builder .NET Client, using Janeva to generate C# code from the IDL files and provide the runtime connectivity between the CORBA server and the .NET client. To add a bit of sauce, although this article doesn't contain an example, Janeva offers the same ease of connectivity to J2EE Enterprise JavaBeans as it does to CORBA Server objects.

Bob Swart  (aka Dr.Bob) is an author, trainer, developer, consultant and webmaster for Bob Swart Training & Consultancy (http://www.eBob42.com) in The Netherlands, who has spoken at Delphi and Borland Developer Conferences since 1993. You can reach Dr. Bob through his Web site at www.drbob42.com.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date