Tutorial: Get started with Windows Communication Foundation applications

The following series of tutorials introduce you to the Windows Communication Foundation (WCF) programming experience. Working through these tutorials in order will give you an introductory understanding of the steps required to create WCF applications. After you finish, you'll have a running WCF service and a WCF client that calls the service.

The tutorial assumes you're using Visual Studio as the development environment. If you're using another development environment, ignore the Visual Studio-specific instructions.

For sample WCF applications that you can download and run, see Windows Communication Foundation samples. For an introduction to the samples, see Getting started sample.

For more in-depth information about creating services and clients, see Basic WCF programming.

gRPC as an alternative to WCF

gRPC is a modern RPC framework that is a popular alternative to WCF. gRPC is built on top of HTTP/2, which provides a number of advantages over WCF, including:

  • Performance: gRPC is much more efficient than WCF, especially for long-running connections.
  • Scalability: gRPC is designed to scale to large numbers of clients and servers.
  • Security: gRPC supports a variety of security mechanisms, including TLS and authentication.
  • Cross-platform: gRPC is platform-neutral and can be used with a variety of programming languages.

For more information on developing or migrating WCF apps to gRPC, see:

WCF tutorials

The first three tutorials describe how to define a WCF service contract, how to implement it, and how to host it. The service that you create is self-hosted within a console application. You can also host services under Microsoft Internet Information Services (IIS). For more information, see How to: Host a WCF Service in IIS. Although you use code to configure the service in the tutorial, you can also configure services within a configuration file.

  • Tutorial: Define a service contract

    You create a WCF contract with a user-defined interface. This contract defines the functionality that the service exposes.

  • Tutorial: Implement a service contract

    After you define a contract, you must implement it with a service class.

  • Tutorial: Host and run a basic service

    Configure an endpoint for the service and host the service in a console application. For a service to become active, you must configure it and host it within a run-time environment. This run-time environment creates the service and controls its context and lifetime.

The next two tutorials describe how to create, configure, and use a client application to call the operations the service exposes. Services publish metadata that define the information a client application needs to communicate with the service. Visual Studio automates the process of accessing this metadata and uses it to construct the client application for the service. If you decide not to use Visual Studio, you can use the ServiceModel Metadata Utility tool (Svcutil.exe) instead.

  • Tutorial: Create a client

    Retrieve metadata for creating a WCF client proxy from a WCF service. You retrieve metadata by using Visual Studio to add a service reference or you can use the ServiceModel Metadata Utility tool. You specify the endpoint that the client uses to access the service.

  • Tutorial: Use a client

    Use the WCF client proxy to call the service operations.

Reference

See also