WCF Hello World Service : Introduction « Windows Communication Foundation « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Text;

using System.ServiceModel;

    [ServiceContract]
    public interface IHelloWCF
    {
        [OperationContract]
        string SayHello();
    }

    public class HelloWCFService : IHelloWCF
    {
        string WCFHelloWorldService.IHelloWCF.SayHello()
        {
            return ("Hello WCF!");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            ServiceHost host = new ServiceHost(typeof(WCFHelloWorldService.HelloWCFService));
            host.Open();
            Console.WriteLine("running.");
            Console.WriteLine("Press <enter> to close host.");
            Console.ReadLine();
            host.Close();
        }
    }








25.1.Introduction
25.1.1.WCF Hello World Service