Introduction to WCF - Chapter- 1

In this chapter we will learn.
1-What is WCF
2-Why should we use WCF

What is WCF?
WCF stands for Windows Communication Foundation and is part of .Net WCF is Microsoft platform for building distributed and interoperable application.

What is a distributed application?
In simple terms a distributed application, is an application where parts of it run on 2 or more computers nodes.  Distributed applications are called as connected systems.

A web application running on one machine and a web services that this’s application is consuming in running on another machine.
Introduction to WCF - Chapter- 1
An enterprise web application may have the following tiers, and each tier may be running on a different machine.

1- Presentation tier
2- Business tier
3- Data Access tier

Introduction to WCF - Chapter- 1
You may be wondering why would summery break down and application in to different tier and why would they deploy those tier on different machine. That’s basically to improve scalability of the application. First let’s understand what is mean by scalability. It means as the no of users increases and you do not want the performance of application to degrade.

Now if you have few visitors to your application than probably you can deploy all of the tier on a single machine because single machine can handle request from few users. But if you expecting 100 thousand of users obviously to handle the request from all of these uses you know you need more hardware more processing capability so what you do as you deploy your tier on different machine and these different machine has got their own processor and memory. So basically they will be able to handle more requests because the presentation logic running on one machine and business logic running on separate machine and data access logic running on separate machine. So instead of having all this logic running on a single machine if we deploy them on different machine obviously they will be handle more request without degrading the performance. So your application will be better scalable.

Why build distributed application?
Why would some body want to build distributed application? There are several reasons for this.
I have listed two of them here.

1- An enterprise application may need to use the services provided by other enterprises.
For Example an eCommerce application may be using PayPal service for payments.

There are 100 thousand of web sites today that sell product. When we purchase product the time of check out you may notice on check out page that you can pay for the item that you have purchased using PayPal. When you click on that button what’s happening there the vender web application there is actually connecting to PayPal service. So basically web application is ruing itself on the windows web server. But PayPal service that application is taking to is running on PayPal web server. So that a connected system there again.

2- For better scalability
An enterprises web application may have presentation tier, Business tier, Data Access tier, and each tier may be running on different machine.

What is an interoperable application?
An application that can communicate with any other application that is built on any platform is called as an interoperable application.

Web services are interoperable, whereas, .Net remoting services are not. Web Services can communicate with any application built on any platform, where as a .net remoting services can be consumed only by another .net application.

We know that Web services are interoperable because they use open protocol and messaging formats. Web service use HTTP protocol and XML message format. Any client any application built on any platform can understand these protocols and open standard obviously Web service are interoperable. But dot net remoting services are interoperable. If have to use dot net remoting services than both the client and server has to be built using dot net.

What technology chooses did we have before WCF to build distributed application?

Enterprises Services
Dot net Remoting
Web Services

Why should we use WCF?
Let's take this scenario
We have 2 clients and we need to implement a service for them.

1. The first client is using a Java application to interact with our service, so for interoperability this client wants messages to be in XML format and the protocol to be HTTP.

2. The second client uses .NET, so for better performance this client wants messages formatted in binary over TCP protocol.

Without WCF
1- To satisfy the first client requirement we end up implementation an ASMX web service.

Introduction to WCF - Chapter- 1
2- The second client is uses .Net, so for better performance this client wants message formatted in binary over TCP protocol. To satisfy the second client requirement we end up implementing a remoting service.

Introduction to WCF - Chapter- 1
Web service and dot Net Remoting are 2 Different technologies, and have complete different programming models. So the developers have to learn different technologies.

With WCF
We implement one service and we can configure as many end points as want to support all the client needs. To support the above 2 client requirements, we would configure 2 end points. In the endpoint configuration we can specify the protocols and message formats that we want to use.

Introduction to WCF - Chapter- 1