// Copyright 2003 Kristopher Johnson #region License // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #endregion using System; using System.Collections; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using Remoting.Corba; using Remoting.Corba.Iop; using Remoting.Corba.Channels.Iiop; // Specify the CORBA interfaces and types to be used by .NET Remoting. namespace CosNaming { [Serializable] public class NameComponent { public string id; public string kind; public NameComponent(string id, string kind) { this.id = id; this.kind = kind; } } public interface NamingContext: ICorbaObject { void rebind(NameComponent[] name, Ior obj); Ior resolve(NameComponent[] name); void unbind(NameComponent[] name); } } namespace Remoting.Corba.Examples.NamingServiceClient { class App { static void Main(string[] args) { try { // register an IIOP channel with the Remoting architecture ChannelServices.RegisterChannel(new IiopClientChannel()); // access the CORBA Naming Service as a remote object if (args.Length != 1) throw new Exception("usage: NamingServiceClient.exe IOR"); string nameServiceIorString = args[0]; CosNaming.NamingContext nameService = (CosNaming.NamingContext) Activator.GetObject( typeof(CosNaming.NamingContext), nameServiceIorString); // create a Naming Service name (a sequence of NameComponents) CosNaming.NameComponent[] name = new CosNaming.NameComponent[1]; name[0] = new CosNaming.NameComponent("TestId", "TestKind"); // bind the name to an object reference nameService.rebind(name, Ior.Parse("corbaloc:iiop:localhost:12345/Test")); // resolve the name Ior iorResolved = nameService.resolve(name); Console.WriteLine("TestId.TestKind IOR is {0}", iorResolved.ToString()); // unbind the name nameService.unbind(name); } catch (Exception ex) { Console.Error.WriteLine("Exception: {0}", ex.ToString()); } } } }