示例#1
0
        static void Main()
        {
            var endpoints = MetadataResolver.Resolve(typeof(ICalculatorService),
                                                    new EndpointAddress("http://localhost:8088/CalculatorService/mex"));

            Console.WriteLine("Welcome in WcfSample Hosting client \n\t#Client Base Sample");
            Console.ReadLine();

            var entity = new CalculatorEntity
            {
                FirstValue = 3.33,
                Calculation = Calculation.Add,
                SecondValue = 4.44
            };

            Console.WriteLine("\n\tMex Sample.");
            Console.WriteLine();

            var clientSelfHosting = new CalculatorServiceClient(endpoints[0].Binding, endpoints[0].Address);
            var result = clientSelfHosting.Invoke(clientSelfHosting.Eval, entity);

            if (result.Success)
                Console.WriteLine(OutputInfo, result.Output);

            Console.WriteLine("Press [Enter] to exit...");
            Console.ReadLine();
        }
示例#2
0
        private static void ExecuteSelfHostedSample(CalculatorEntity entity)
        {
            Console.WriteLine("\n\tSelf-hosting sample.");
            Console.WriteLine();

            var clientSelfHosting = new CalculatorServiceClient("WSHttpBinding_CalculatorService_SelfHosted");
            ServiceInvoker.ServiceResult<double> result = clientSelfHosting.Invoke(clientSelfHosting.Eval, entity);
            Console.WriteLine(OutputInfo, result);
        }
示例#3
0
        private static void ExecuteIISSample(CalculatorEntity entity)
        {
            Console.WriteLine("\n\tIIS Sample.");
            Console.WriteLine();

            var iisServiceClient = new CalculatorServiceClient("WSHttpBinding_CalculatorService");
            var result = iisServiceClient.Invoke(iisServiceClient.Eval, entity);

            if (result.Success)
                Console.WriteLine(OutputInfo, result);
        }
示例#4
0
        private static void ExecuteDivideByZeroSample(CalculatorEntity entity)
        {
            Console.WriteLine("\tSelf-hosting sample - divide by zero");
            Console.WriteLine();

            CalculatorServiceClient clientSelfHosting = new CalculatorServiceClient("WSHttpBinding_CalculatorService_SelfHosted");
            entity.Calculation = Calculation.Divide;
            entity.SecondValue = 0;
            ServiceInvoker.ServiceResult<double> result = clientSelfHosting.Invoke(clientSelfHosting.Eval, entity);

            if (result.Success)
                Console.WriteLine(OutputInfo, result.Output);
        }