WCF is one skill which is currently have become a must know thing in .Net Web Development interview questions. To start with in this blog I discussed about WCF(Windows Communication Foundation) and its evolution, how it is different from previous technologies(Problems) and then WCF advantages. Answering to why use WCF?
From history in early 1980s we were had the Monolithic Application development. In monolithic application everything resides in one program at one single platform, like user interface, data access code & business logics all in one program makes it a huge application. Monolithic applications are independent self-contained and don’t implement reusability. Foxfro and Microsoft access are examples.
Next in later 1980s Object Orientated concepts came in picture were we have code- reusability concepts. It’ is the extension over structured programming i.e. code and data moved onto an object state (data) and behavior (code). Major thing added here is reusability in which user write a class and this class can be used anywhere to create object from that. Problem: Reusability was up to application level only no language interoperability. Class are static to an application level only if any small changes made whole application need to be rebuild.
Then onward COM (Component Object Model) came in the picture (1993) in which we write a code and reuse it in many applications and also language inter-operability was there. Deploy it anywhere in our machine and use it enable inter-process communication and dynamic object creation. Problem: Tight coupling an developed application is tightly coupled with a particular COM. So any time application need to build/run then that particular COM should always be there on that machine i.e. localize to a machine and not available over network.
After this DCOM (Dynamic Component Object Model) came in i.e. COM over network. One of Microsoft biggest failure then release COM+(2000-01) i.e. DCOM with transaction service to enable using COM component over network have object pooling and just in time activation features.
Next then onward with the .Net evolution replacement provided with .Net Remoting. Remoting basically used for developing distributed application. Problem: Both client and server needs to be on same network. Protocol used not friendly on internet so then Web Service came into picture.
Web Service was a major break change to the things. Object functionality provided over network. Service are deployed and clients use it services using HTTP protocol. Data exchange over the network is in standard XML format SOAP communication. Web Services are interoperable on different platform on different languages and different technologies i.e. like a web service developed in Java can be consumed by .Net Client.
WCF(Windows Communication Foundation) are the next generation to web services introduced with .NET 3.0 framework(2006). Provide a common umbrella.
How WCF is different from Traditional Web Services?
- Compared to old web service which are confined to use HTTP protocol only In WCF we can use TCP, MSMQ and other protocols.
- Messages In WCF could be send using other format than SOAP like REST, old xml(POX).
- Web Service are hosted only on webserver while WCF can be hosted as a single standalone application (Windows/Console Applications)& window services.
- In WCF have feature to manage transaction and reliable session which was not available with web services.
- In Webservices we have stateless objects but in WCF we are free to use stateful objects.