Tech Brief

Windows Communication Foundation

The skinny on Microsoft's programming model for messaging.

Do you write code that needs to communicate with other software? Microsoft's Windows Communication Foundation (WCF) is a single, unified programming model for messaging that supports all communications protocols and transports.

Developers no longer have to learn to use every communications protocol. Tools and project templates are available for WCF in Visual Studio 2008, which is in beta now and expected to ship next year. These tools -- combined with the use of attributes and configuration files -- make for a highly productive dev environment.

Part of .NET Framework 3.0, WCF enables the development of secure, reliable, transacted services that interoperate with non-Microsoft platforms. It combines and extends the capabilities of Microsoft's existing distributed systems technologies, including Enterprise Services, MSMQ, .NET Remoting, WSE v3.0 and ASMX.

WCF has three main strengths: Interoperability, productivity and a service-oriented development focus. It supports the common Web service Basic Profile 1.0 and the WS-* specifications.

With service-orientation, you retain the benefits of self-describing applications, explicit encapsulation and dynamic loading of functionality. What changes is the metaphor with which you accomplish it. Instead of using method invocation on an object reference, developers rely on message passing. In addition, to support dynamic loading of service-based functionality, a schema is used to describe the structure of messages, a behavioral contract to define acceptable message exchange patterns and policy to define service semantics.

ABC's of WCF
In WCF, you create a service endpoint from an "Address," a "Binding" and a "Contract"-the ABC's of creating a WCF service. In developing a service, you run through the ABC's in reverse and create the contract first. A contract is built as an interface in .NET, and each method to be exposed via the service endpoint is marked with the [OperationContract] attribute.
Once the contract is defined, the address, binding, contract and any other miscellaneous configuration can be specified in an XML config file that you can edit in Visual Studio 2008 with the WCF Configuration Editor tool. The binding specifies any channels to be used and includes any transports and protocols that the messaging takes place over. The address is an identification of where the endpoint is; the address format depends upon the binding chosen.

Messaging Scenarios
Using the unified programming model that WCF provides enables many different messaging scenarios:

  • REST Web HTTP, in .NET 3.5, is a binding that includes template-based URI addressing, explicit support for content types and HTTP GET-based retrieval of information.
  • Syndication Web HTTP, in .NET 3.5, is a binding that formats data using RSS or ATOM syndication formats. Internet Explorer 7.0 can be used as a client for this kind of service.
  • AJAX Web HTTP, in .NET 3.5, is a binding for services that are compatible with AJAX clients where a Web service may be called from a Web browser without a full-page update. These services support the JSON encoding format and are highly scalable services supporting ASP.NET AJAX applications.
  • Basic HTTP is a binding that has binary compatibility with WS-I Basic Profile Web services. These are the Web services that can be built with Visual Studio .NET 2003 and Visual Studio 2005 and are known as ASMX SOAP Web services.
  • .NET TCP is a binding that offers high performance using the TCP transport and binary (non-XML) formatting. This is an optimal binding for cross-machine communications where both endpoints are using WCF.
  • .NET named pipe is a binding that uses shared memory to message between two processes on a single machine. Although this binding requires both service and client to be on the same machine it provides the most performance possible in that scenario.
  • .NET peer is a binding for messaging between peer nodes on a network.

Compact Framework
Lastly, there's a new implementation of WCF coming out at the same time as .NET Framework 3.5. The .NET Compact Framework 3.5 includes a subset of WCF features, including Web service support with WS-Security and a new store and forward communications channel. The store and forward channel uses activesync and e-mail to send and receive messages. This means that messages can be addressed to an individual mobile device by using the e-mail address.

Visual Studio 2008 WCF
[click image for larger view]
Visual Studio 2008 will include the WCF Configuration Editor tool for creating address, binding and contract configs.
Messages can also be sent while the device is offline as they're stored in the e-mail account and synchronized when the device goes online for e-mail sync. This enables scenarios that have not been possible before for mobile applications, and it builds on a transport mechanism that's often already in place and reliably configured.
comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube