Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage Articles Book Published: Essential Windows Communication Foundation

Book Published: Essential Windows Communication Foundation


With the release of Windows Communication Foundation 3.5 Microsoft overhauled its APIs, web service infrastructure, as well as its tooling with Visual Studio 2008.  Published by Addison Wesley, Essential Windows Communication Foundation  is authored by Steve Resnick, Richard Crane, and Chris Bowen and intended to provide developers with a roadmap relying heavily on sample code.

The follwing is a short QnA with the authors, please feel free to add your questions/comments for the authors:

Q: What are the largest differences in WCF when moving 2.0 to 3.5 that developers should acquaint themselves with?

I’d group the differences into three buckets. First is the support for REST-style programming, which is a bit more developer-friendly than SOAP. With 3.5, WCF includes URI templates for mapping web addresses and HTTP verbs, for implementing JSON and RSS formats, and for binary streams. Second, is the integration between WCF and WF, the Workflow Foundation of .NET. This is so powerful because WCF and WF are really two sides of the same coin: WCF is the interface and hosting environment for the service, while WF implements its processing logic. The third big change for WCF 3.5, is actually in Visual Studio 2008, which now has designers and debugging tools for WCF. There are useful WCF and WF templates and there are handy tools like WcfSvcHost and WCFTestClient that streamline testing.

Q: What new feature in WCF 3.5 are you most excited about and why?

I think the way WCF 3.5 supports REST-style protocols is pretty cool. To be clear, there are significant differences between SOAP and REST, where SOAP is primarily concerned with action (verbs) and REST is more oriented towards entities (nouns). But because of the “behavior” architecture in the WCF, the programming model doesn’t change much when you switch between the two. I find this pretty amazing, that you can switch between two architecture models (REST vs. SOAP) yet still code the same way for the other 90% of an application.

Q: When designing and implementing services what guidance can you provide to architects and developers?

Just as you prioritize the features that you support in your application, you should also prioritize the infrastructure. For instance, which is more important… performance, scalability, manageability, interoperability, security, time-to-market? Once you prioritize this, look at your choices. And for each one, choose the simplest option that meets your needs. If you’re looking for standard http-based access and custom (userid/password) authentication then use basicHttpBinding and IIS for hosting. But if you need get super-fast performance on an internal network, leverage Windows Activation Services (on Windows 2008) and netTcpBinding. Also, there’s great diagnostics tools built into .NET 3.5. Learn to use the service trace utility – it will save you time.

Q: Why should developers use WCF for non-SOAP based services like JSON and AJAX?

WCF has amazing support for services, whether they’re exposed via SOAP or other protocols. Attributes like threading, instancing, auditing, security and hosting are important regardless of the protocol. Prior to 3.5, accessing a WCF service from an AJAX app was pretty hard. But with the new support, and with samples readily available, it’s pretty easy. It turns out that the protocol is the easy part; it’s the other attributes (threading, security, etc.) where WCF will save you time.

Q: Do you have any favorite tools for tracing or debugging WCF services you would like to share with the community?

For starters, there’s an end-to-end tracing facility and a logging built into WCF that makes it fairly easy to track what’s going on when messages are sent and received. There’s a viewer that shows you each step in the process, and it even color-codes entries in red when a failure is detected. The Service Configuration Editor makes it easy to turn tracing on and off. Second, you can instrument a service using performance counters so you can monitor key attributes of your application. This is helpful in production; not just development. And third, using WCF Behaviors, you can create your own auditing facility and log anything you’d like. You can log to a database, to a queue, or whatever makes most sense for your situation.

Q: What is the question you are most asked that you would like to provide a pre-emptive response to?

Everyone asks about performance. Of course that’s a loaded topic because it depends on what features are required! For instance, if you need interoperable message-level security, then you’ll want to use WS-Security, Text encoding and HTTP for broadest reach. This is pre-configured using the wsHttpBinding. On the other hand, if you control the client, service and network, then you can use binary encoding, TCP as the protocol. This is pre-configured using netTcpBinding and delivers 5x performance! And this doesn’t require any code changes. Same is true with instancing. Do you need to single-thread your classes or can you allow WCF to spin up multiple instances simultaneously? The later delivers much better concurrency. WCF supports either model though InstanceContext setting. Again, WCF gives you the flexibility to tune performance to exactly meet your needs. Very cool indeed!

InfoQ is pleased to provide our readers with a hosted chapter from the book Essential Windows Communcation Foundation, Chapter 13.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p