United StatesChange | All Microsoft Sites
Windows Communication Foundation

Windows Communication Foundation (WCF) is Microsoft’s platform for SOA. It is a rich technology foundation designed for building distributed service-oriented applications for the enterprise and the web that are secure, reliable, transactional and scalable. This document summarizes the overall value proposition of WCF – highlighting key benefits, application scenarios and core features.

WCF Releases and Platform Support

.NET 3.0 was released to manufacturing in November 2006 and officially launched with Windows Vista in January 2007 – introducing WCF along with Windows Workflow Foundation (WF) and Windows Presentation Foundation (WPF). This marked the release of Microsoft’s first class web services platform simplifying the design, implementation and deployment of services with essential plumbing for scalability, performance, security, reliable message delivery, transactions, multithreading, asynchronous messaging and more.

With .NET 3.5 – launched with Visual Studio 2008 in November 2007 – additional WCF features were introduced including:

  • Built-in support for web programming models such as Plain Old XML (POX), Representational State Transfer (REST), JavaScript Object Notation (JSON) and syndication feeds such as Really Simple Syndication (RSS) and ATOM.
  • Support for the latest web service standards
  • Better integration with ASP.NET AJAX clients
  • Support for partial trust environments. For example, hosting environments that run ASP.NET with reduced trust can host WCF services, and clients running with reduced trust – such as JavaScript within a browser or ClickOnce applications – can use WCF proxies.
  • Support for custom execution contexts and durable long running services
  • Seamless integration between WCF and WF allowing for services to be written as workflows and workflows to invoke services
  • Productivity tools directly integrated with Visual Studio 2008

WCF applications can be deployed to the following platforms: Windows XP (SP2 or higher), Windows Vista, Windows Server 2003, and Windows Server 2008.

A Platform for SOA

Service Oriented Architecture (SOA) is the evolution of component-oriented programming making it possible to encapsulate, reuse and distribute business functionality with the added benefit of interoperability across technology platforms. Adopting a service-oriented approach to system design provides a cleaner separation between business logic and the protocols over which that business logic is reached – making systems more flexible, optimized for the deployment scenario, and more easily maintainable. Services provide a natural boundary for security and for distribution and scale-out. Exposing functionality via interoperable services can also open new marketing channels as the system gains a wider reach.

WCF was built with SOA in mind:

  • Service design and implementation are naturally decoupled from application business logic, making it easy to migrate existing applications to a service-oriented design without rewriting existing components
  • Services expose functionality to remote clients through explicit contracts using an opt-in approach
  • Services execute autonomously with no impact to one another in the event of failure
  • Services can be deployed over different protocols to satisfy a variety of distributed computing scenarios
  • Services support interoperability with major vendors
  • Services can be exposed directly on the web, in an intranet, or used in the backend of the enterprise

Unified Programming Model

WCF is the evolution of Enterprise Services/COM+, .NET Remoting, System.Messaging, ASP.NET Web Services (ASMX) and Web Services Enhancements (WSE) – all technologies that in that past were employed to satisfy very different distributed computing scenarios. WCF satisfies all of these scenarios including interoperable web services; Web 2.0 programming models such as POX, REST, JSON and RSS/ATOM; classic client-server scenarios; high performance calls across process and machine boundaries behind the firewall; and durable, reliable queued messaging on top of Microsoft Message Queuing (MSMQ).

A single, unified programming model supports each of these scenarios thus the developer experience is consistent for service design, configuration and deployment. Prior to WCF developers had to learn a different technology and object model to support different distributed computing needs – with WCF they can apply their knowledge of a single platform to satisfy all scenarios. This makes it easy to employ appropriate protocols at each tier to optimize communications in any system. In addition, this is a huge productivity boost for development and maintenance. A service may be designed and implemented once and then exposed in a number of different scenarios.

Developer Productivity

There are many aspects of WCF that facilitate developer productivity for building distributed, service-oriented systems, including:

  • Visual Studio 2008 includes a suite of templates and tools for generating WCF projects and services, and for configuring the runtime environment for service deployment.
  • WCF provides essential plumbing for building a service-oriented system which means that developers can focus on the business problem at hand instead of writing code related to system features such as security, reliable delivery, transactions, multithreading, and messaging queuing.
  • Services can be hosted in any Windows process including Internet Information Services (IIS), Windows Activation Services (WAS), Windows NT Services, and Windows Forms or WPF client applications. Developers can choose the hosting environment appropriate for the application scenario, and where possible take advantage of the built-in hosting features provided by IIS and WAS.

Application Scenarios

WCF promotes loose coupling of service design, hosting environment and configuration of protocols required to support communications. Developers design services to encapsulate business functionality – independent of deployment requirements. The appropriate hosting environment and communication protocols can be later selected for the application scenario. The following sections will summarize a few typical scenarios where WCF is widely employed including the core features that support each scenario.

Enterprise Web Services

Enterprise web services are services based on the SOAP protocol and may also employ any number of advanced web service standards (collectively known as WS*). These standards facilitate secure, reliable, transactional, and fully interoperable message exchange. Applications typically rely on these standards for interoperable messaging across platforms and technologies, and to expose services that are accessible over Internet or through firewalls.

Microsoft's commitment to open standards has been demonstrated throughout the evolution of web services as a technology. ASP.NET web services (ASMX) supported early versions of SOAP protocol and Web Services Enhancements (WSE) – an add-on to ASMX – provided early implementations of WS* protocols. WCF continues this trend providing built-in support for all of the latest WS* protocols including:

  • Messaging: SOAP, WS-Addressing, MTOM
  • Metadata: WSDL, WS-MetadataExchange, WS-Policy
  • Security: WS-Security, WS-SecureConversation, WS-Trust
  • Reliability and Transactions: WS-ReliableMessaging, WS-Coordination, WS-AtomicTransaction

WCF also supports earlier versions of the WS* protocols that were adopted by WSE along with many non-Microsoft platforms – for backward compatibility. Enabling support for WS* protocols is as simple as selecting an appropriate binding configuration for the WCF service. The details of the protocol implementation are completely transparent to developers.

Web Programming Models

Web 2.0 programming paradigms have become increasingly popular for building Rich Internet Applications (RIA) that rely on JavaScript as in AJAX, Silverlight and other similar client technologies to produce graphical web interfaces rich in media and interactive content. As of .NET 3.5 WCF provides built-in support for the following alternate messaging styles that are appropriate for Web 2.0:

  • POX – Simplified XML messaging without the formality of SOAP protocol.
  • REST – An alternative to SOAP that often relies on POX at its core. It is an architectural style that leverages a URI-based pattern for accessing resources over the Internet.
  • JSON – A lightweight messaging format that is an alternative to XML. It is specifically useful for JavaScript clients to exchange data with services with less transfer and processing overhead.
  • RSS/ATOM – Syndication formats based on XML. They are specifically useful for sharing sequentially updated data feeds such as blog entries.

What these messaging styles do not provide for are the secure, reliable and transactional delivery semantics of enterprise web services – but they do simplify access to content from JavaScript and web clients, and reduce overhead. Once again, developers rely on the same programming model to implement services that support these formats. .NET 3.5 made this easier by providing a number of new declarative attributes, bindings and configuration settings to easily select the desired format.

Intranet Applications

Intranet applications typically live behind the firewall, rely on the Windows domain for authentication and authorization, and do not require interoperable protocols. In the past .NET Remoting or Enterprise Services would be used to expose business functionality across process and machine boundaries behind the firewall in support of this scenario. With WCF, developers use the same familiar programming model to design, host and configure services – but they can select an appropriate set of protocols for the differences in security models and for optimized performance.

Intranet services are often used in the following scenarios:

  • Classic client-server applications where Windows clients communicate with services behind the firewall.
  • ASP.NET web clients that leverage services behind the firewall that may also be distributed to downstream application servers.
  • Distribution of services across any process or machine boundaries as part of a service-oriented system design which is also useful for introducing necessary security boundaries and supporting horizontal scale-out requirements.

Intranet applications leverage WCF’s optimized binary messaging formats and as such rely on WCF to be on both ends of the communication.

Disconnected Messaging

Asynchronous, disconnected messaging patterns facilitate loosely coupled communications within a service-oriented application making it possible to execute long running processes without waiting on a response; to provide load leveling; and to guarantee message delivery even if services, equipment or networks are temporarily offline. Microsoft Message Queuing (MSMQ) is a messaging platform that supports these scenarios. WCF services can receive messages from a queue in support of asynchronous and disconnected scenarios – instead of receiving messages directly from a connected client application. With this functionality you can design systems that rely on messaging for scenarios such as:

  • Guaranteed message delivery
  • Reducing the overhead of synchronous calls to longer running operations
  • Supporting disconnected scenarios
  • Distributing work among available server resources
  • Implementing disconnected publish and subscribe scenarios

Configuring a WCF service to listen on a message queue is a simple as selecting the correct binding configuration that supports MSMQ protocol.

Workflow Services

A long running and complex business process is often best described with workflow technology – which brings visibility to the process, increases predictability, and reduces overhead through automation. New features released with .NET 3.5 introduce new ways for workflows defined with WF to more directly interact with WCF services, including:

  • Workflows can be exposed as WCF services making it easier for remote client applications to send messages that interact directly with a workflow instance at appropriate points of execution that support it.
  • Workflows can directly call WCF services which makes it easier to implement a long running process that relies on functionality exposed by multiple services within a service-oriented application.

Workflows also support persistence, which means that a workflow exposed as a WCF service may also be a durable service that saves the workflow and service state. This allows system resources associated with the workflow to be released during idle time, and reloaded when clients interact with the workflow instance once again.

Durable services can also be leveraged independent of workflow services. A durable service uses the persistence services exposed by WF so that services supporting sessions can automatically save state after an operation is called, and recapture that state when a new call arrives within the same session.