教程:开始使用 Windows Communication Foundation 应用程序Tutorial: Get started with Windows Communication Foundation applications

以下一系列教程向您介绍了为 Windows Communication Foundation (WCF) 编程体验。The following series of tutorials introduce you to the Windows Communication Foundation (WCF) programming experience. 通过按顺序这些教程将提供初步了解创建 WCF 应用程序所需的步骤。Working through these tutorials in order will give you an introductory understanding of the steps required to create WCF applications. 完成后,你必须正在运行的 WCF 服务和 WCF 客户端调用服务。After you finish, you'll have a running WCF service and a WCF client that calls the service.

本教程假定你正在使用 Visual Studio 作为开发环境。The tutorial assumes you're using Visual Studio as the development environment. 如果你使用的另一个开发环境,忽略的 Visual Studio 的特定说明。If you're using another development environment, ignore the Visual Studio-specific instructions.

对于示例 WCF 应用程序可以下载并运行,请参阅Windows Communication Foundation 示例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.

有关创建服务和客户端的更多详细信息,请参阅基本 WCF 编程For more in-depth information about creating services and clients, see Basic WCF programming.

WCF 教程WCF tutorials

前三个教程介绍如何定义 WCF 服务协定、 如何实现它,以及如何承载它。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. 此外可以托管在 Microsoft Internet Information Services (IIS) 服务。You can also host services under Microsoft Internet Information Services (IIS). 有关详细信息,请参阅如何:承载在 IIS 中的 WCF 服务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

    使用用户定义的接口创建 WCF 协定。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 自动化访问此元数据的过程,并使用它来构造服务的客户端应用程序。Visual Studio automates the process of accessing this metadata and uses it to construct the client application for the service. 如果你决定不使用 Visual Studio,则可以使用ServiceModel 元数据实用工具 (Svcutil.exe)相反。If you decide not to use Visual Studio, you can use the ServiceModel Metadata Utility tool (Svcutil.exe) instead.

  • 教程:创建客户端Tutorial: Create a client

    检索用于创建 WCF 客户端代理从 WCF 服务的元数据。Retrieve metadata for creating a WCF client proxy from a WCF service. 使用 Visual Studio 添加服务引用检索元数据,或者可以使用 ServiceModel 元数据实用工具的工具。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

    使用 WCF 客户端代理调用服务操作。Use the WCF client proxy to call the service operations.

参考Reference

请参阅See also