public static void Main(string[] args) { try { string nameServiceHost = "localhost"; int nameServicePort = 1050; parseArgs(ref nameServiceHost, ref nameServicePort, args); Console.WriteLine("input the two summands"); Console.WriteLine("sum1:"); double sum1 = Double.Parse(Console.ReadLine()); Console.WriteLine("sum2:"); double sum2 = Double.Parse(Console.ReadLine()); // register the channel IiopClientChannel channel = new IiopClientChannel(); ChannelServices.RegisterChannel(channel, false); // access COS nameing service RmiIiopInit init = new RmiIiopInit(nameServiceHost, nameServicePort); NamingContext nameService = init.GetNameService(); NameComponent[] name = new NameComponent[] { new NameComponent("ch.elca.iiop.demo.ejbAdder.AdderHome", "") }; // get the reference to the adder-home AdderHome adderHome = (AdderHome)nameService.resolve(name); // create Adder Adder adder = adderHome.create(); // call add double result = adder.add(sum1, sum2); Console.WriteLine("result: " + result); // dispose the ejb adder.remove(); } catch (Exception e) { Console.WriteLine("exception: " + e); } }
public void SetupEnvironment() { // register the channel m_channel = new IiopClientChannel(); ChannelServices.RegisterChannel(m_channel, false); // access COS nameing service RmiIiopInit init = new RmiIiopInit("localhost", 7001); m_nameService = init.GetNameService(); NameComponent[] name = new NameComponent[] { new NameComponent("IntegrationTest", ""), new NameComponent("test", "") }; // get the reference to the test-home TestHome testhome = (TestHome) m_nameService.resolve(name); m_test = testhome.create(); }
public static void Main(string[] args) { try { string nameServiceHost = "localhost"; int nameServicePort = 1050; parseArgs(ref nameServiceHost, ref nameServicePort, args); // register the channel IiopClientChannel channel = new IiopClientChannel(); ChannelServices.RegisterChannel(channel, false); // access COS nameing service RmiIiopInit init = new RmiIiopInit(nameServiceHost, nameServicePort); NamingContext nameService = init.GetNameService(); // test value object: Console.WriteLine("testing value object"); NameComponent[] name = new NameComponent[] { new NameComponent("ch.elca.iiop.demo.valueObjectDemo.ValueObjDemoHome", "") }; // get the reference to the ValObjectDemo-home ValObjectDemoHome valDemoHome = (ValObjectDemoHome)nameService.resolve(name); // create valObjectDemo ValObjectDemo valDemo = valDemoHome.create(); // call retrieveValObject Console.WriteLine("calling retrieveValObject"); ValObject resultVal = valDemo.retrieveValObject(); Console.WriteLine("test-string: " + resultVal.testString); Console.WriteLine("test-int: " + resultVal.testValue); // call echoValObject Console.WriteLine("calling echoValObject"); ValObject toSend = new ValObjectImpl(); Console.WriteLine("input string: "); toSend.testString = Console.ReadLine(); Console.WriteLine("input int: " ); toSend.testValue = Int32.Parse(Console.ReadLine()); Console.WriteLine("result of echo: "); ValObject echo = valDemo.echoValObject(toSend); Console.WriteLine("echo-string: " + echo.testString); Console.WriteLine("echo-value: " + echo.testValue); // Dispose the EJB valDemo.remove(); } catch (Exception e) { Console.WriteLine("exception: " + e); } }
public static void Main(string[] args) { try { string ejbNameServiceHost = "localhost"; int ejbNameServicePort = 7001; if (args.Length > 0) { ejbNameServiceHost = args[0]; } if (args.Length > 1) { ejbNameServicePort = Int32.Parse(args[1]); } // the port the callback is listening on int callbackPort = 0; // auto assign if (args.Length > 2) { callbackPort = Int32.Parse(args[2]); } IiopChannel channel = new IiopChannel(callbackPort); ChannelServices.RegisterChannel(channel, false); RmiIiopInit init = new RmiIiopInit(ejbNameServiceHost, ejbNameServicePort); NamingContext nameService = init.GetNameService(); NameComponent[] name = new NameComponent[] { new NameComponent("demo", ""), new NameComponent("chatroomHome", "") }; // get the chatroom home interface ChatroomHome home = (ChatroomHome) nameService.resolve(name); Chatroom chatroom = home.create(); Application.Run(new Chatform(chatroom)); } catch (Exception e) { Console.WriteLine("exception: " + e); } }
private bool submit_CID_objects() { try { string regAppID = utility.getParameter("CID_RFG_application_id"); #region if an EJB is provided - similar to http://iiop-net.sourceforge.net //register the channel if not already registered bool registered = false; for (int i = 0; i < ChannelServices.RegisteredChannels.Length; i++) { if (ChannelServices.RegisteredChannels[i].ChannelName == "IIOPChannel") { registered = true; } } if (!registered) { IiopClientChannel channel = new IiopClientChannel(); //.NET 1.1: ChannelServices.RegisterChannel(channel); ChannelServices.RegisterChannel(channel, false); } // get the naming service //old RmiIiopInit init = new RmiIiopInit("ccecidut04.cce.hp.com", 7302); string cidHost = utility.getParameter("CID_nameService_host"); int cidPort = Int32.Parse(utility.getParameter("CID_nameService_port")); //RmiIiopInit init = new RmiIiopInit("sasuit1cl3.austin.hp.com", 22777); RmiIiopInit init = new RmiIiopInit(cidHost, cidPort); NamingContext nameService = init.GetNameService(); //NameComponent[] name = new NameComponent[] { new NameComponent("com.hp.cid.ejb.identity.IdHome", "") }; //NameComponent[] name = new NameComponent[] { new NameComponent("com.hp.cid.ejb.identity", "") }; //NameComponent[] name = new NameComponent[] { new NameComponent("com.hp.cid.identity", "") }; //NameComponent[] name = new NameComponent[] { new NameComponent("identity", "") }; //NameComponent[] name = new NameComponent[] { new NameComponent("identity_ejb", "") }; NameComponent[] name = new NameComponent[] { new NameComponent(utility.getParameter("CID_nameServiceID"), "") }; //IdHome idHome = (IdHome)nameService.resolve(name); //Id identObj = idHome.create(); Id identObj = (Id)nameService.resolve(name); #endregion #region if an EJB is provided - similar to www.codeproject.com // doesn't work!! // //register the channel // IiopClientChannel channel = new IiopClientChannel(); // ChannelServices.RegisterChannel(channel); // // // get the naming service // RmiIiopInit init = new RmiIiopInit("ccecidut04.cce.hp.com", 7302); // NamingContext nameService = (NamingContext)init.GetService("NameServiceServerRoot"); // // NameComponent[] name = new NameComponent[] { new NameComponent("identity_ejb", "") }; // Id identObj = (Id)nameService.resolve(name); #endregion #region if a nameing server is used // string nameServiceHost = utility.getParameter("CID_nameService_host"); // int nameServicePort = int.Parse(utility.getParameter("CID_nameService_port")); // // //access COS nameing service // CorbaInit init = CorbaInit.GetInit(); // // NamingContext nameService = init.GetNameService(nameServiceHost, nameServicePort); // NameComponent[] name = new NameComponent[] {new NameComponent("identity", "")}; // // //get the reference to the serive class // Id identObj = (Id)nameService.resolve(name); #endregion #region if an IOR file is used //string ior = utility.getParameter("CID_IOR"); //string ior = "iiop://ccecidut04.cce.hp.com:7302/identity_ejb"; //get the reference to the serive class //Id identObj = (Id)RemotingServices.Connect(typeof(Id), ior); #endregion #region call getIDPlus bool returnAddressIdFlag = true; bool returnAddressFlag = true; bool returnPrivacyFlag = true; bool single_submit = false; for(int i = 0; i < cid_records.Length; i++) { CidPerson hpCust = cid_records[i]; single_submit = false; if (!cid_results[i].submitted) { try { //bool result = identObj.verifyID("2100000002006857", regAppID); //string id = ""; //me susann old: "2100000002006857" //object o = identObj.getPerson("0000000001268848", regAppID); //CidPerson me_susann = identObj.getPerson(id, regAppID); CidNumberObject returned_cid = identObj.getIDPlus(hpCust, "", returnAddressIdFlag, returnAddressFlag, returnPrivacyFlag); single_submit = (returned_cid.personIdentifier.Length > 0); cid_results[i].CidIdentifier = String.Format("infoClient: getIDPlus() returns = {0}{1}", returned_cid.personIdentifier, utility.newline); } catch (Exception ex) { #region //log OMG CORBA exception, connection or cidexception error? string exceptionMessage = ""; if (ex.GetType().ToString() == "com.hp.cid.exceptions.CidException") { com.hp.cid.exceptions.CidException cidEx = (com.hp.cid.exceptions.CidException)ex; exceptionMessage = GetCidExceptionString(cidEx); } else { exceptionMessage = ex.ToString(); } cid_results[i].FailureMessage = exceptionMessage; #endregion single_submit = false; } cid_results[i].submitted = single_submit; } } #endregion return true; } catch (Exception ex) { //log connection error ? //wrong IiopClientChannel channel = new IiopClientChannel(); //wrong ChannelServices.UnregisterChannel(channel); //for (int i = 0; i < ChannelServices.RegisteredChannels.Length; i++) //{ // ChannelServices.UnregisterChannel(ChannelServices.RegisteredChannels[i]); //} string exception = ex.ToString(); return false; } }