Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var binding  = new BasicHttpBinding();
            var endpoint = new EndpointAddress("http://localhost:8000/SEP");

            try
            {
                var client = new HelloServiceClient(binding, endpoint);

                while (true)
                {
                    Console.Clear();
                    ShowHelp();

                    var name = Console.ReadLine();
                    if (string.IsNullOrEmpty(name))
                    {
                        break;
                    }

                    var ret = client.SayHello(name);

                    Console.WriteLine(ret);
                    Console.WriteLine("Hit <ENTER> to continue");
                    Console.ReadLine();
                }

                Console.ReadLine();
                client.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     IHelloService svc = new HelloServiceClient();
     Console.WriteLine(svc.SayHello("luis"));
     Console.ReadLine();
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Channel channel = new Channel("localhost:9000", ChannelCredentials.Insecure);

            // Single message
            var    client = new HelloServiceClient(channel);
            String user   = "******";

            var reply = client.SayHello(new Common.Messages.HelloNameRequest {
                Name = user
            });

            Console.WriteLine("Basic hello world!");
            Console.WriteLine("Greeting: " + reply.Message);
            Console.WriteLine("*****************************************************************");

            // message with type
            const int years     = -7;
            long      dateValue = DateTime.Today.AddYears(years).Date.Ticks;
            var       response2 = client.SayHelloWithDetails(new Common.Messages.HelloRequest
            {
                Name = user, Age = Math.Abs(years), IsHappy = true, DateOfBirthLong = dateValue
            });

            Console.WriteLine("Hello with type.");
            Console.WriteLine("Greeting: " + response2.Message);
            Console.WriteLine("*****************************************************************");

            // List of messages
            var request3 = new Common.Messages.HelloListRequest();

            request3.Names.Add("rahman");
            request3.Names.Add("maria");
            request3.Names.Add("hosha");
            request3.Names.Add("roya");
            request3.Names.Add("cyrus");
            var response3 = client.SayHelloList(request3);

            Console.WriteLine("Hello list.");
            foreach (var item in response3.Names)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine("*****************************************************************");

            // Stream list
            var listOfNames = new List <string>()
            {
                "rahman",
                "maria",
                "hosha",
                "roya",
                "cyrus"
            };

            Console.WriteLine("Hello stream.");
            foreach (var name in listOfNames)
            {
                var streamRequest = new Common.Messages.HelloStreamListRequest();
                streamRequest.Names.Add(name);
                var streamResponse = client.SayHelloListStream(streamRequest);

                foreach (var item in streamResponse.Names)
                {
                    Console.WriteLine(item);
                }

                Thread.Sleep(1000); // simulating a stream!!!
            }
            Console.WriteLine("*****************************************************************");

            channel.ShutdownAsync().Wait();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }