WCF and Bindings
(Page 1 of 4 )
In this third article in a five-part series on using the Windows Communication Foundation (WCF), you will learn how to choose and configure a binding, and more. It is excerpted from chapter one of
Programming WCF Services, written by Juval Lowry (O'Reilly, 2007; ISBN: 0596526997). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.
Choosing a Binding
Choosing a binding for your service should follow the decision-activity diagram shown in Figure 1-4.
The first question you should ask yourself is whether your service needs to interact with non-WCF clients. If the answer is yes, and if the client is a legacy MSMQ client, choose theMsmqIntegrationBindingthat enables your service to interoperate over MSMQ with such a client. If you need to interoperate with a non-WCF client and that client expects basic web service protocol (ASMX web services), choose theBasicHttpBinding, which exposes your WCF service to the outside world as if it were an ASMX web service (that is, a WSI-basic profile). The downside is that you cannot take advantage of most of the modern WS-* protocols. However, if the non-WCF client can understand these standards, choose one of the WS bindings, such asWSHttpBinding, WSFederationBinding, orWSDualHttpBinding. If you can assume that

Figure 1-4. Choosing a binding
the client is a WCF client, yet it requires offline or disconnected interaction, choose theNetMsmqBindingthat uses MSMQ for transporting the messages. If the client requires connected communication, but could be calling across machine boundaries, choose theNetTcpBindingthat communicates over TCP. If the client is on the same machine as the service, choose theNetNamedPipeBindingthat uses named pipes to maximize performance. You may fine-tune binding selections based on additional criteria such as the need for callbacks (WSDualHttpBinding) or federated security (WSFederationBinding).
Most bindings work well even outside their target scenario. For example, you could use the TCP binding for same-machine or even in-proc communication, and you could use the basic binding for Intranet WCF-to-WCF communication. However, do try to choose a binding according to Figure 1-4.
Using a Binding
Each binding offers literally dozens of configurable properties. There are three modes of working with bindings. You can use the built-in bindings as is if they fit your requirements. You can tweak and configure some of their properties such as transaction propagation, reliability, and security. You can also write your own custom bindings. The most common scenario is using an existing binding almost as is, and merely configuring two or three of its aspects. Application developers will hardly ever need to write a custom binding, but framework developers may need to.
Next: Endpoints >>
More Windows Scripting Articles
More By O'Reilly Media
|
This article is excerpted from chapter one of Programming WCF Services, written by Juval Lowry (O'Reilly, 2007; ISBN: 0596526997). Check it out at your favorite bookstore. Buy this book now.
|
|