示例#1
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("-----");
            }
        }
示例#2
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("-----");
            }
        }