public string RequestLongestPrefix(string addr, string query) //192.168.56.1:8080
        {
            ChannelFactory <IPalindromeService> factory = null;
            string answer;

            try
            {
                BasicHttpBinding binding = new BasicHttpBinding();
                EndpointAddress
                    address = new EndpointAddress("http://" + addr + "/MagicEightBallService");
                factory = new ChannelFactory <IPalindromeService>(binding, address);
                IPalindromeService channel = factory.CreateChannel();
                answer = channel.GetLongestPalindromePrefix(query);
                factory.Close();
            }
            catch (Exception ex)
            {
                if (factory != null)
                {
                    factory.Abort();
                }
                answer = ex.ToString();
            }
            return(answer);
        }
예제 #2
0
        static void Main(string[] args)
        {
            ChannelFactory <IPalindromeService> factory = null;

            try
            {
                WSHttpBinding   binding = new WSHttpBinding();
                EndpointAddress address = new EndpointAddress("http://localhost:8000/PalindromeService2");
                factory = new ChannelFactory <IPalindromeService>(binding, address);
                IPalindromeService channel = factory.CreateChannel();
                Console.Write("Enter your line: ");
                string question = Console.ReadLine();
                string answer   = channel.GetLongestPalindromePrefix(question);
                Console.WriteLine("Longest palindrome prefix : {0}", answer);
                factory.Close();
            }
            catch (Exception ex)
            {
                factory?.Abort();
                Console.WriteLine(ex.ToString());
            }
            Console.ReadLine();
        }