Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            HttpChannel channel = new HttpChannel();

            ChannelServices.RegisterChannel(channel);

            Console.WriteLine("Acqu. Rem. Instance");
            IRemoteFactory fact = (IRemoteFactory)Activator.GetObject(
                typeof(IRemoteFactory),
                "http://localhost:1234/factory.soap");

            Console.WriteLine("Client.Main(): Acquiring object from factory");
            IRemoteObject obj1 = fact.getNewInstance();

            Console.WriteLine("Client.Main(): Sleeping one second");
            System.Threading.Thread.Sleep(1000);

            Console.WriteLine("Client.Main(): Setting value");
            try
            {
                obj1.setValue(42);
            }
            catch (Exception e)
            {
                Console.WriteLine("Client.Main(). EXCEPTION \n{0}", e.Message);
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            HttpChannel channel = new HttpChannel();

            ChannelServices.RegisterChannel(channel);

            Console.WriteLine("Client.Main(): Creating factory");
            IRemoteFactory fact = (IRemoteFactory)Activator.GetObject(
                typeof(IRemoteFactory),
                "http://localhost:1234/factory.soap");

            Console.WriteLine("Client.Main(): Acquiring first object from factory");
            IRemoteObject obj1 = fact.getNewInstance();

            obj1.setValue(42);

            Console.WriteLine("Client.Main(): Acquiring second object from factory");
            IRemoteObject obj2 = fact.getNewInstance(4711);

            Console.WriteLine("Obj1.getValue(): {0}", obj1.getValue());
            Console.WriteLine("Obj2.getValue(): {0}", obj2.getValue());

            Console.ReadLine();
        }