Monday, February 11, 2008

WCF - Windows Communication Foundation

WCF, WCF, WCF it seems that since the initial release of .NET Framework 3.0, Everyone has been talking about WCF. For those of you who don't know, WCF is Microsoft's Amalgamation of the following technologies and services into one set of libraries for the .NET Framework 3.0. Specifically these are the area of web services (improved), Message Queuing, COM+, DCOM and .NET Remoting.

Personally from experience I would have though WF (Workflow) would have been the big piece everyone is talking about, but it seems the combination of WF and WCF is what everyone is talking since SOA (Service Oriented architectures) is the big buzz word these days. So I ask myself, what's the real benefit or using WCF and why does every company under the sun that I talk to want this technology? Well the answer in my opinion is that it really opens up you design architecture of the traditional component based modeling for development and allows you to expose your libraries as services, rather than as stand alone DLLs.

At first like most new technologies, I asked, why should I change to this methodology or technology? It was pretty much the same question I asked when I was a junior developer, why do we need to write wrappers? After converting some of my existing business layer project to WCF, I started to see the benefits where WCF can play a MAJOR role in your architecture because no longer do you need to copy DLL's to have clients access your data, you can expose your internal data as a service which long term allows you to plug in additional technologies and work with multiple platforms.

I took a simple example of the following ASP.NET web page. Normally, for me to pull a Dataset from a database, I would have my business layer connect to my data access layer then to the database. Normally, the ASP.NET Web page, would require you to add a direct reference to the business logic component. With the WCF project, I took all the methods of the business object and exposed them as WCF services. At first, this seemed silly to me, because my Web Site was grabbing information from another web server, when it could just access the database directly. Then I thought, well, now my WPF, Win32 and even open source programs that can reference SOAP API's will be able to grab data from the same business components. Best of All, I could use all of IIS's features such as security, load balancing and SSL to provide a very efficient and secure way of managing my data. Best of all, if I wanted to expose my business components or services to the rest of the world, it's ready!

But then I asked, "what about performance?". Well WCF has improved, and WCF to WCF calls are all using SOAP Binary. After finding this out, I was sold! All the business components I develop now that needs to be exposed to Presentation interfaces, I now exposes as Web Services on WCF. This is not even using the advanced features such as Queuing or Remoting. But it's great to know that if I want to use this with my components, I can!

Maybe I'll even do this with my database abstraction layer (probably not but the idea sounded interesting).

With workflow, I can now create a business process workflow using WF, host it inside a WCF service and then throw that out to the clients. A great way to have loosely coupled services, and true SOA!

Some people think that this maybe overkill, exposing all of your business components as WCF services, but I think this is the future with web services. You also never know when you will need that integration or flexibility, so with WCF you definitely have this flexibility.

You can read up more on WCF at MSDN.

I recommend the Apress Book Professional WCF - Practical Microsoft SOA Implementation.

I also recommend you take one of your existing projects and add WCF to it so you can really see how the technology applies to your business, once you do, you won't go back!

If you want to truly abstract your Presentation layer, I think WCF is great because you can take all of your exposing business logic, throw it into a WCF project, recompile, host the service in IIS and then have your clients add the reference to the web service.

No comments: