示例#1
0
        public static void Main(string[] args)
        {
            ChannelFactory <IDispatching> factory =
                new ChannelFactory <IDispatching>("DispatchingService");
            IDispatching channel = factory.CreateChannel();

            try
            {
                MSG add       = channel.dispatch(new MSG("add", "tok", new Object[] { 1, 2 }));
                MSG sub       = channel.dispatch(new MSG("sub", "tok", new Object[] { 4, 5 }));
                MSG operror   = channel.dispatch(new MSG("div", "tok", new Object[] { 1, 2 }));
                MSG tok_error = channel.dispatch(new MSG("add", "wrongtok", new Object[] { 1, 2 }));
                Console.WriteLine(add.DataTable[0]);
                Console.WriteLine(sub.DataTable[0]);
                Console.WriteLine(operror.DataTable[0]);
                Console.WriteLine(tok_error.DataTable[0]);
            }
            catch
            {
                factory.Abort();
                throw;
            }
            if (factory.State == CommunicationState.Opened)
            {
                factory.Close();
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            DispatchingClient factory = new DispatchingClient("DispatchingService");
            IDispatching      service = factory;

            try
            {
                MSG addParam = new MSG();
                addParam.AppToken  = "tok";
                addParam.DataTable = new Object[] { 4, 5 };
                addParam.OpName    = "add";
                MSG add = service.dispatch(addParam);
                //MSG sub = service.dispatch(new MSG("sub", "tok", new Object[] {4, 5}));
                //MSG operror = service.dispatch(new MSG("div", "tok", new Object[] {1, 2}));
                //MSG tok_error = service.dispatch(new MSG("add", "wrongtok", new Object[] {1, 2}));
                Console.WriteLine(add.DataTable[0]);
                //Console.WriteLine(sub.DataTable[0]);
                //Console.WriteLine(operror.DataTable[0]);
                //Console.WriteLine(tok_error.DataTable[0]);
            }
            catch
            {
                factory.Abort();
                throw;
            }
            factory.Close();
        }