Build a small 'hello world' console application:
The client calls a function provided by a remote server, with the following signature 'string hello(string)' and displays the result.
Write the CORBA IDL, generate C# code from IDL, and write server & client application in Visual Basic accessing the generated C# code.
module Hello { interface Greetings { string hello( in string a_strName); }; }; |
> BrewerCmd.exe -o Hello Hello.idl |
This creates a C# Shared DLL named Hello.dll.
a.) Create a console application.
b.) Add a reference to '$ESPRESSO_INSTALL_DIR$\bin\Jintegra.Espresso.dll'
c.) Add a reference to the new DLL.
d.) Write an implementation for the IDL (within HelloSrv.vb):
Public Class Greetings Inherits Hello.GreetingsPOA Sub New() End Sub Public Overrides Function Hello(ByVal strMyName As String) As String Console.WriteLine("Function 'Hello' Parameter '{0,20}'", strMyName) Hello = "Greetings to " + strMyName End Function End Class |
e.) Write the server (HelloSrv.vb):
Initialize the CORBA ORB using RuntimeConfiguration:Dim rc As RuntimeConfiguration rc = New RuntimeConfiguration rc.SetApplicationLog(OrbErrorLevel.ERRORS, "SrvLog.log", False) rc.SetORBEndpoint("localhost", 1357, 0) Dim orb As Ics.CORBA.ORB orb = Ics.CORBA._ORB.init(rc) |
Dim poa As Ics.PortableServer.POA poa = Ics.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA")) |
poa.the_POAManager.activate() |
Dim oGreetings As Greetings oGreetings = New Greetings() Dim obj As Ics.CORBA.Object obj = poa.servant_to_reference(oGreetings) |
Dim strIORFile As String strIORFile = "c:\\hello.ior" Ics.CORBA._ORB.wrIORtoFile(strIORFile, obj) |
orb.run(); |
a.) Create a console application.
b.) Add a reference to '$ESPRESSO_INSTALL_DIR$\bin\Jintegra.Espresso.dll'
c.) Add a reference to the new DLL.
d.) Write the client (HelloClt.vb):
Initialize the CORBA ORB using RuntimeConfiguration:Dim rc As RuntimeConfiguration rc = New RuntimeConfiguration rc.SetApplicationLog(OrbErrorLevel.ERRORS, "CltLog.log", False) Dim orb As Ics.CORBA.ORB orb = Ics.CORBA._ORB.init(rc) |
Dim strIORFile As String strIORFile = "file://c:\\hello.ior" Dim obj As Ics.CORBA.Object obj = orb.string_to_object(strIORFile) |
Dim oGreetings As Hello.Greetings oGreetings = Hello.GreetingsHelper.narrow(obj) |
Console.WriteLine("Call Hello '{0}' returned '{1}'", "Santa Claus", oGreetings.hello("Santa Claus")) |
a.) Start the Server.
b.) Start the Client.