Hello Indigo – A Simple WCF Service

[code:c#]

namespace Microsoft.Samples{    using System;    using System.ServiceModel;    using System.ServiceModel.Channels;    class SimpleService    {        static void Main(string[] args)        {            Binding binding = new NetTcpBinding();            string address = "net.tcp://localhost";            ServiceHost host = new ServiceHost(typeof(EchoService), new Uri(address));            host.AddServiceEndpoint(typeof(IEchoService), binding, "");            host.Open();            ChannelFactory cf = new ChannelFactory(binding, address);            IEchoService proxy = cf.CreateChannel();            Console.WriteLine(proxy.Echo("Hello Indigo."));            ((IChannel)proxy).Close();            host.Close();        }    }    [ServiceContract]    interface IEchoService    {        [OperationContract]        string Echo(string input);    }    class EchoService : IEchoService    {        public string Echo(string input)        {            return "Echo : " + input;        }    }}

[/code]

SimpleService.cs (1.07 kb)