InfoQ

News

WCF Communication Options in the .NET Framework 3.5

Posted by Hartmut Wilms on Jan 16, 2008 12:39 PM

Community
.NET,
SOA
Topics
.NET Framework ,
SOA Platforms ,
SOA Appliance
Tags
WCF

David Chappell, Principal of Chappell & Associates, presents the various communication styles provided by Windows Communication Foundation (WCF) in his white paper called "Dealing with Diversity: Understanding WCF Communication Options in the .NET Framework 3.5".

Windows Communication Foundation is Microsoft's approach of providing a single programming model for the diverse set of communication options faced when developing distributed systems. The set of options ranges from inter process communication to peer-to-peer networking. In the past each communication model dictated a specific programming model. "By providing a common programming model for many kinds of communication, it can help developers work more effectively with diversity", says David Chappell.

The whitepaper starts by introducing the two main WCF concepts that are responsible for working with diversity:

From the beginning, WCF’s creators recognized that applications had diverse communication needs. They also believed that new kinds of communication were certain to appear. To address this reality, WCF provides a general architecture for supporting different communication styles. The two big ideas in this architecture are channels and bindings [...].

In WCF every interaction is viewed as a message exchange. Messages consist of a payload and an arbitrary amount of infrastructure data including its transport. In order to cope with the diverse set of existing and future communication alternatives, WCF introduced the channel model. Each channel is dedicated to a specific infrastructure aspect, e.g. security or reliability. The complete set of infrastructure needs of a single communication option is handled by a predefined or custom channel stack:

Whether acting as a client, a service, or both, all software that communicates via WCF relies on one or more channels. [...] a stack of channels is created between a WCF client or service and the communication mechanism it relies on. The lowest channel in this stack always does the same job: It maps the message being sent to whatever mechanism is used to transport that message. Accordingly, this bottom component is known as the transport channel.

WCF allows to easily configure and define a channel stack by introducing bindings:

By specifying a particular binding, a WCF client or service implicitly creates a channel stack that implements a particular set of communication behaviors. [...] The service defined by a particular WCF interface might be accessible via just one binding [...] or simultaneously accessible via more than one binding [...].

After explaining the architecture David Chappell presents all communication options offered by the .NET Framework 3.5:

SOAP and WS-* Web Services

Being Microsoft's approach to service-oriented architecture WCF is built to develop SOAP/WS-* web services:

  • WCF allows to send SOAP/WS-* messages over an arbitrary transport, e.g. HTTP or TCP.
  • The most important WS-Specifications are supported - MSDN provides an extensive overview of Web Services Protocols Supported by System-Provided Interoperability Bindings in .NET Framework 3.5.
  • Services can be forced to conform to the Web Services Interoperability Organization (WS-I) Basic Profile 1.0.
  • WCF provides a set of predefined bindings for the most common web service scenarios. 

Binary Communication between WCF Applications

In the event of WCF-To-WCF communication

WCF supports communication using a more efficient binary encoding. Rather than sending standard XML-based SOAP messages over HTTP, a developer can choose to send a more efficient representation of the same information directly over TCP.

RESTful Web Services

Since the REST approach to web services gains more and more popularity, WCF supports a RESTful style in the .NET Framework 3.5. Although the fact that the first version of WCF was focused on SOAP-based services, the "quite general channel model makes adding support for RESTful communication straightforward". At first WCF messages have to get rid of the SOAP envelope and its headers, which is accomplished by using the newly added WebHttpBinding:

Unlike the [other] HTTP-based bindings [...] this one uses an encoding option that’s new in the .NET Framework 3.5 release of WCF: WebMessageEncoding. This option doesn’t add or remove SOAP headers. Instead, it implements three different options for representing content: text-based XML encoding, JSON encoding, and opaque binary encoding, which is useful for things such as conveying JPEG files. And like its fellow HTTP bindings, WebHttpBinding can also be configured to use HTTPS for greater security.

Operations are mapped to HTTP verbs, e.g. GET, PUT, POST or DELETE, by annotating the WCF Service Contract with the WebGet or WebInvoke attributes. In Because the RESTful style "necessarily means working with URIs", WCF provides a means of managing "large numbers of similar URIs": URI templates. "The goal of these templates is to make it easier for developers to express URI patterns and work with URIs that match those patterns".

POX and Syndication (RSS, ATOM)

Sending Plain Old XML (POX) messages or using a syndication format is supported by using WCF's RESTful model:

POX, RSS, and ATOM are all formats—they’re not protocols. Because of this, no special WCF binding is required to use them. All are usually sent directly over HTTP, with no SOAP header, and so the best binding choice is typically WebHttpBinding.

Communication with Line-Of-Business (LOB) Applications

WCF supports developing clients that communicate with applications that do not provide a web service interface:

One important example of this is communicating with a line-of-business (LOB) application, such as SAP. [...] 

Allowing this is the goal of the WCF Line-of-Business (LOB) Adapter SDK. As the “SDK” in its name suggests, this technology doesn’t itself include any adapters. Instead, it provides tools and a runtime environment to help create adapters to LOB applications. These adapters can then be used by application developers to create WCF clients that use the services of an LOB application just as if that application were an ordinary WCF service.
 

Communication via Message Queues

In order to communicate with message queues

[...] WCF provides an MSMQ transport channel. To use queued communication, a developer creates a standard WCF service, marking its interface and methods with the ServiceContract and OperationContract attributes as usual. Each operation in this interface must also be marked with the IsOneWay property on the OperationContract attribute [...]

Only binary messages are send via MSMQ, either wrapped by a SOAP envelope or without using a SOAP envelope.

Communication via Windows Peer-To-Peer Networking

Windows peer-to-peer networking  is mainly used for collaboration scenarios. Single PCs act as clients and servers (peers) within a peer system. 

As usual, WCF applications can use Windows peer-to-peer networking by specifying the correct binding. The NetPeerTcpBinding [...] relies on a transport channel that’s specific to peer communication. This binding also puts in place a PnrpPeerResolver channel that handles addressing for messages sent to a particular graph of peer systems.
 

Interprocess Communication

WCF supports [communication between processes on the same machine] using the NetNamedPipeBinding [...]. Rather than relying on a transport channel that implements a networking protocol, such as HTTP or TCP, this binding uses a transport channel that communicates via named pipes, a standard Windows mechanism for interprocess communication.

Custom Communication

WCF provides many ways of extending and customizing communication options. Developers may create custom channels, custom bindings and customize the existing bindings. David Chappell presents Microsoft BizTalk Services, that "provide an interesting illustration of this".

 

According to David Chappell "a general-purpose platform for communication makes good sense". WCF is "supporting a diversity of communication styles within a common framework", that can easily be expanded or customized.

No comments

Watch Thread Reply

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.