예제 #1
0
        static void AccessService1()
        {
            try
            {
                var proxy = new MessageServiceClient();
                proxy.SetUserNameAndPassword("hhoangvan", "hhoangvan");

                var message = new MessageDto()
                {
                    Message = "Hello request/reply"
                };

                proxy.SendMessage(message);
                proxy.LogMessage(message);

                var result = proxy.GetAll();

                Console.WriteLine("Results: " + result.Count());
            }
            catch (Exception ex)
            {
                Console.WriteLine("-----");

                while (ex != null)
                {
                    Console.WriteLine(ex.Message);
                    ex = ex.InnerException;
                }

                Console.WriteLine("-----");
            }
        }
예제 #2
0
        static void SendMessage(string message)
        {
            try
            {
                var proxy = new MessageServiceClient();
                proxy.SetUserNameAndPassword("hhoangvan", "hhoangvan");
                proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;

                var messageDto = new MessageDto()
                {
                    Message = message,
                    SentAt = DateTime.Now
                };

                proxy.SendMessage(messageDto);
                proxy.LogMessage(messageDto);
                proxy.GetAll();

                proxy.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("-----");

                while (ex != null)
                {
                    Console.WriteLine(ex.Message);
                    ex = ex.InnerException;
                }

                Console.WriteLine("-----");
            }
        }
예제 #3
0
        static void AccessService0()
        {
            try
            {
                var proxy = new MessageServiceClient();
                proxy.SetUserNameAndPassword("hhoangvan1", "hhoangvan1");

                var token = proxy.AuthorizeClient();
                Console.WriteLine("Token " + token);
            }
            catch (Exception ex)
            {
                Console.WriteLine("-----");

                while (ex != null)
                {
                    Console.WriteLine(ex.Message);
                    ex = ex.InnerException;
                }

                Console.WriteLine("-----");
            }
        }