What Is Windows Communication Foundation - WCF (2024)

  • Article

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data. A few sample scenarios include:

  • A secure service to process business transactions.

  • A service that supplies current data to others, such as a traffic report or other monitoring service.

  • A chat service that allows two people to communicate or exchange data in real time.

  • A dashboard application that polls one or more services for data and presents it in a logical presentation.

  • Exposing a workflow implemented using Windows Workflow Foundation as a WCF service.

While creating such applications was possible prior to the existence of WCF, WCF makes the development of endpoints easier than ever. In summary, WCF is designed to offer a manageable approach to creating Web services and Web service clients.

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:

  • Why we recommend gRPC for WCF developers
  • Comparing WCF to gRPC
  • Introduction to gRPC for WCF developers

Features of WCF

WCF includes the following set of features. For more information, see WCF Feature Details.

  • Service Orientation

    One consequence of using WS standards is that WCF enables you to create service oriented applications. Service-oriented architecture (SOA) is the reliance on Web services to send and receive data. The services have the general advantage of being loosely-coupled instead of hard-coded from one application to another. A loosely-coupled relationship implies that any client created on any platform can connect to any service as long as the essential contracts are met.

  • Interoperability

    WCF implements modern industry standards for Web service interoperability. For more information about the supported standards, see Interoperability and Integration.

  • Multiple Message Patterns

    Messages are exchanged in one of several patterns. The most common pattern is the request/reply pattern, where one endpoint requests data from a second endpoint. The second endpoint replies. There are other patterns such as a one-way message in which a single endpoint sends a message without any expectation of a reply. A more complex pattern is the duplex exchange pattern where two endpoints establish a connection and send data back and forth, similar to an instant messaging program. For more information about how to implement different message exchange patterns using WCF see Contracts.

  • Service Metadata

    WCF supports publishing service metadata using formats specified in industry standards such as WSDL, XML Schema and WS-Policy. This metadata can be used to automatically generate and configure clients for accessing WCF services. Metadata can be published over HTTP and HTTPS or using the Web Service Metadata Exchange standard. For more information, see Metadata.

  • Data Contracts

    Because WCF is built using the .NET Framework, it also includes code-friendly methods of supplying the contracts you want to enforce. One of the universal types of contracts is the data contract. In essence, as you code your service using Visual C# or Visual Basic, the easiest way to handle data is by creating classes that represent a data entity with properties that belong to the data entity. WCF includes a comprehensive system for working with data in this easy manner. Once you have created the classes that represent data, your service automatically generates the metadata that allows clients to comply with the data types you have designed. For more information, see Using Data Contracts.

  • Security

    Messages can be encrypted to protect privacy and you can require users to authenticate themselves before being allowed to receive messages. Security can be implemented using well-known standards such as SSL or WS-SecureConversation. For more information, see Security.

  • Multiple Transports and Encodings

    Messages can be sent on any of several built-in transport protocols and encodings. The most common protocol and encoding is to send text encoded SOAP messages using the HyperText Transfer Protocol (HTTP) for use on the World Wide Web. Alternatively, WCF allows you to send messages over TCP, named pipes, or MSMQ. These messages can be encoded as text or using an optimized binary format. Binary data can be sent efficiently using the MTOM standard. If none of the provided transports or encodings suit your needs you can create your own custom transport or encoding. For more information about transports and encodings supported by WCF see Transports.

  • Reliable and Queued Messages

    WCF supports reliable message exchange using reliable sessions implemented over WS-Reliable Messaging and using MSMQ. For more information about reliable and queued messaging support in WCF see Queues and Reliable Sessions.

  • Durable Messages

    A durable message is one that is never lost due to a disruption in the communication. The messages in a durable message pattern are always saved to a database. If a disruption occurs, the database allows you to resume the message exchange when the connection is restored. You can also create a durable message using the Windows Workflow Foundation (WF). For more information, see Workflow Services.

  • Transactions

    WCF also supports transactions using one of three transaction models: WS-AtomicTransactions, the APIs in the System.Transactions namespace, and Microsoft Distributed Transaction Coordinator. For more information about transaction support in WCF see Transactions.

  • AJAX and REST Support

    REST is an example of an evolving Web 2.0 technology. WCF can be configured to process "plain" XML data that is not wrapped in a SOAP envelope. WCF can also be extended to support specific XML formats, such as ATOM (a popular RSS standard), and even non-XML formats, such as JavaScript Object Notation (JSON).

  • Extensibility

    The WCF architecture has a number of extensibility points. If extra capability is required, there are a number of entry points that allow you to customize the behavior of a service. For more information about available extensibility points see Extending WCF.

WCF Integration with Other Microsoft Technologies

WCF is a flexible platform. Because of this extreme flexibility, WCF is also used in several other Microsoft products. By understanding the basics of WCF, you have an immediate advantage if you also use any of these products.

The first technology to pair with WCF was the Windows Workflow Foundation (WF). Workflows simplify application development by encapsulating steps in the workflow as "activities." In the first version of Windows Workflow Foundation, a developer had to create a host for the workflow. The next version of Windows Workflow Foundation was integrated with WCF. That allowed any workflow to be easily hosted in a WCF service. You can do this by automatically choosing the WF/WCF project type in Visual Studio 2012 or later.

Microsoft BizTalk Server R2 also utilizes WCF as a communication technology. BizTalk is designed to receive and transform data from one standardized format to another. Messages must be delivered to its central message box where the message can be transformed using either a strict mapping or by using one of the BizTalk features such as its workflow engine. BizTalk can now use the WCF Line of Business (LOB) adapter to deliver messages to the message box.

The hosting features of Windows Server AppFabric application server are specifically designed for deploying and managing applications that use WCF for communication. The hosting features include rich tooling and configuration options specifically designed for WCF-enabled applications.

See also

  • System.ServiceModel
  • Fundamental Windows Communication Foundation Concepts
  • Windows Communication Foundation Architecture
  • Guidelines and Best Practices
  • Getting Started Tutorial
  • Guide to the Documentation
  • Basic WCF Programming
  • Windows Communication Foundation Samples
What Is Windows Communication Foundation - WCF (2024)

FAQs

What Is Windows Communication Foundation - WCF? ›

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another.

What functions does WCF Windows Communication Foundation support? ›

WCF supports several messaging patterns, including request-reply, one-way, and duplex communication. Different transports support different messaging patterns, and thus affect the types of interactions that they support.

What is the difference between Windows presentation Foundation and Windows Communication Foundation? ›

WCF is for service-oriented software solutions, and WPF is for developing the UI of a . NET app. In addition, both technologies can be used together. It can help you enhance the interface as well as the data-sharing capabilities of your enterprise-grade software.

What are the 3 things that a WCF services endpoint must have? ›

The three major points in WCF are the address, contract, and binding. The address defines the location of the services. The contract specifies the interface between the client and the service. And the binding defines how the two parties, the client and the service, will communicate with each other.

Is WCF still used? ›

Windows Communication Framework (WCF) may be deprecated in . NET 5/6+, but it doesn't mean your applications are going to be left out in the cold. Just like Web Forms and other . NET Framework technologies, your WCF applications will continue to work for a long time.

What is WCF and why is it used? ›

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.

Why is WCF needed? ›

Need for WCF

WCF unified all these into a single service development framework with the following goals: Provide a unified programming model for building services across transport protocols like HTTP, TCP, Named Pipes etc. Enable services to expose multiple endpoints and bindings simultaneously.

What is Windows presentation foundation used for? ›

WPF provides a comprehensive set of application-development features that include Extensible Application Markup Language (XAML), controls, data binding, layout, 2D and 3D graphics, animation, styles, templates, documents, media, text, and typography.

What is the difference between Windows Communication Foundation and Web Services? ›

Web services support only one protocol- HTTP and HTTPS during communication, but WCF supports more protocols like- HTTP, TCP, and MSMQ that can be extended for a comprehensive solution, reliable session, and transactions. It signifies WCF is more adaptable to work together for a variety of software.

What are the different types of WCF? ›

WCF contract specify the service and its operations. WCF has five types of contracts: service contract, operation contract, data contract, message contract and fault contract.

How to use WCF service in client application? ›

Follow these steps:
  1. Create a Visual Studio Project. ...
  2. Add the controls to the Form. ...
  3. Add a Service Reference for the WCF service. ...
  4. Add C# code to call your WCF service. ...
  5. Compile and run your client application. ...
  6. Close the client application and the running WCF service.
Dec 8, 2022

What is the endpoint address in WCF? ›

Address: The address uniquely identifies the endpoint and tells potential consumers of the service where it is located. It is represented in the WCF object model by the EndpointAddress class. An EndpointAddress class contains: A Uri property, which represents the address of the service.

What has replaced WCF? ›

gRPC as a migration path for WCF to .

NET Core and . NET 5 marks a shift in the way that Microsoft delivers remote communication solutions to developers who want to deliver services across a range of platforms. . NET Core and . NET 5 support calling WCF services, but won't offer server-side support for hosting WCF.

Does Microsoft still support WCF? ›

Due to some breaking changes, we're extending the end of support date for WCF Client 4.10 until November 12, 2024. The following list shows the details of the support policy for WCF Client: WCF Client uses the Major. Minor versioning strategy.

What is better than WCF? ›

Web API is the best option for writing mobile devices and device-oriented services. WEB API is easier to learn, requiring less configuration than WCF. If there is a service written in WCF at your workplace (which is very likely) you need to know WCF to accompany it.

What can WCF communicate with? ›

WCF includes predefined bindings for most common communication protocols such as SOAP over HTTP, SOAP over TCP, and SOAP over Message Queues, etc. Interaction between WCF endpoint and client is done using a SOAP envelope. SOAP envelopes are in simple XML form, which makes WCF platform-independent.

What to replace WCF with? ›

If WCF is used in a project, this poses an additional challenge in porting. First, an alternative needs to be found, and then a preparatory transition of WCF is required. Microsoft generally recommends two alternatives, gRPC and Web API, to replace WCF.

References

Top Articles
Latest Posts
Article information

Author: Jonah Leffler

Last Updated:

Views: 6238

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Jonah Leffler

Birthday: 1997-10-27

Address: 8987 Kieth Ports, Luettgenland, CT 54657-9808

Phone: +2611128251586

Job: Mining Supervisor

Hobby: Worldbuilding, Electronics, Amateur radio, Skiing, Cycling, Jogging, Taxidermy

Introduction: My name is Jonah Leffler, I am a determined, faithful, outstanding, inexpensive, cheerful, determined, smiling person who loves writing and wants to share my knowledge and understanding with you.