Windows Communication Foundation (WCF) – Introduction

Welcome to the WCF tutorial series for the .NET Framework 3.5. In this introduction you will learn what WCF is, how it fits into the .NET ecosystem, and the basic concepts you need to start building service-oriented applications.

What is WCF?

Windows Communication Foundation (WCF) is a unified programming model for building service-oriented applications. It enables developers to create secure, reliable, and transactable services that can be consumed across platforms and protocols.

Core Concepts

Service Contract

A service contract defines the operations that a service exposes. In .NET, this is expressed using an interface marked with the [ServiceContract] attribute.

using System.ServiceModel;

[ServiceContract]
public interface ICalculator
{
    [OperationContract]
    double Add(double a, double b);
}

Bindings and Endpoints

Bindings specify how the service communicates with clients (transport, encoding, security). An endpoint ties together an address, a binding, and a contract.

<system.serviceModel>
  <services>
    <service name="CalculatorService">
      <endpoint address="" binding="basicHttpBinding"
                contract="ICalculator" />
    </service>
  </services>
</system.serviceModel>

Hosting a Service

WCF services can be hosted in IIS, Windows services, or self‑hosted applications.

using System;
using System.ServiceModel;

class Program
{
    static void Main()
    {
        using (ServiceHost host = new ServiceHost(typeof(CalculatorService)))
        {
            host.Open();
            Console.WriteLine("Service is running...");
            Console.ReadLine();
        }
    }
}

Security Overview

WCF provides a rich security model covering transport security, message security, authentication, and authorization. For example, enabling transport security over HTTPS:

<binding name="SecureHttpBinding">
    <security mode="Transport">
        <transport clientCredentialType="None" />
    </security>
</binding>

Next Steps

Continue to the next tutorial to build a simple WCF service.

Creating a Service →