In this article we are going to see an introduction to Windows Communication Foundation. WCF is a unified programming model for building service oriented distributed applications . Lets go down the History of Distributed applications . The Monolithic applications gave way to applications built with components using COM ( Component Object Model ) . Monolithic applications would mean where everything exists with a single exe or a application . Using COM you could create components which would do particular tasks and COM would make these applications available to you . This was good for the Desktop applications . But what about the Web world . So Desktop COM make way for Distributed COM . So now COM components could be hosted on the Server and your application could access this COM components . DCOM further evolved into COM+ and intergrated with the Transaction Server . So all your datalogic and Business log would now run on a Central Server and you could now have transactions supported as well. And then came .NET , and rather than completely rewrite the Business Logic . The .Net components can now use Enterprise Services to Leverage COM+. Another option to build distributed applications was Remoting. .NET Remoting consists of a client and remote objects hosted on a server . Client can access remote objects as if they are local . Enterprise Services and .NET Remoting require client , components and data to be on the same network . But what happends when that is not the case . What happens when you client and data to be accessed by the Client are not in the same netwrok . Web Services Solves this problem . Web Services enable you to pass data as XML over Internet . Now the Client and Server to pass the XML back and forth both Client and Server need to agree upon how the xml looks like . That's where SOAP comes in . Simple Object Access Protocol defines structure of XML messages clients and services pass . Visual Studio helps us create and comsume Web Services easily without much trouble . So this approach of Building Distributed applications is called Service orientation . A Service is a program that performs a task and that you can interact with through well defined messages . In other words we can say that a Service Oriented application consists of loosely coupled services that communicate through messages and contracts. Messages are the actual messages that go back and forth and contracts are basically the interfaces that define what the service will do . They are Loosely coupled because the Client does not instantiate the Service . So this is a major difference between a Service oriented architecture or say a COM component model where the Client would have to instantiate the Server Class . In the Service Oriented Architecture the Client does not instantiate the Service , instead it just passes the method . So there is a Shift from remotely invoking components to passing messages between services . Principles of Service Orientation :
Services can define the circumstances under which clients can communicate with them. So at this point you must be getting a question are Web Services Service Oriented . The answer is Yes . So we already have a Service Oriented technology working great for us . So why go for WCF . Why do we developers have to learn another technology. Whats wrong with what we have . Too many ways to create a distributed applications . Too many options are not good as well . WebServices ( SOA ) and Enterprise Services , .NET Remoting ( not SOA). Which should you use and when Do you need interoperability ? Are you going over the Internet or over TCP ? Are you accessing services internally or externally ? In simple terms WCF is a one word solution to all our problems . WCF comes to the Rescue :
If you had to expose the WCF Externally you would expose it on HTTP and if you had to expose the WCF Internally you could do it on TCP and you could expose both on same time as well. Lets also discuss the most common question everyone asks when starting with WCF. WCF Vs WebServices : I promise that there is gone be only one Winner . WCF Has the following features over Web Services :
In the next post we will start creating our first WCF Service .
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: