WCF Part 2: Fundamentals.
Dec15

WCF Part 2: Fundamentals.

Welcome to CodeSpread! We have seen the evolution of WCF in our previous article: WCF Part 1: Why WCF?. Next, we will go through the fundamentals of WCF. I will try to make it more worthy than an interview question puff. What is WCF? Windows Communication Foundation.Easy. Although, I was not able to find as why it is called a foundation but I was able to relate it to the fact that WCF was the first attempt to bring all the communication protocols and messaging formats under one roof.Refer last article for details. With WCF in hand,No developer have to go anywhere or learn new technology to create a distributed system. Definition: As per Wikipedia, “Windows Communication Foundation is a runtime and a set of APIs (application programming interface) in the .NET Framework for building connected, service-oriented applications”. MSDN, “Windows Communication Foundation (WCF) is Microsoft’s unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and inter-operate with existing investments.” Our definition, “ WCF provides a flexible way of developing service oriented applications. Flexibility in terms of communication protocols,message formats, security options, transactions and it covers almost all the existing platforms and also supports older versions to a certain extent”. It means WCF is a one stop solution for a service oriented paradigm. What is the fundamental knowledge required? Communication between server and client happens by exchanging messages over a network which must be following a transport protocol. What are these messages? “A self-contained unit of data that can consist of several parts, including a body and headers.” If you have a xml file or json or any other format which fits into this criteria can be termed as message. These messages are first encoded before being sent. we have following encoding options available. Text encoding : “ Text is translated into numeric values and numeric values are rendered as visible characters. This can happen by using an encoding standard like UTF-8, UTF-16.” Message Transmission Optimization Mechanism (MTOM) encoding: “MTOM is a mechanism for transmitting large binary attachments with SOAP messages as raw bytes, allowing for smaller messages.” Binary encoding: “Binary encoding relies on bits, the smallest unit of encoding.” What is this transport protocol? HTTP : Hyper text transfer Protocol, a request/response protocol for internet. Browsers can understand HTTP. Easy! TCP : Transmission Control Protocol,requires dedicated connection between client and the server. Named Pipes : An object in Windows O/S kernel which facilitates communication between processes on a single machine. Message Queues : Not exactly a transport protocol, MSMQ is essentially a messaging protocol that allows applications running on separate servers/processes...

Read More
WCF Part 1: Why WCF?
Dec12

WCF Part 1: Why WCF?

When i create a WCF service, i feel like it is a very easy task but when somebody asks me, why you have created it? then the simplest answer is, i got the requirement like this. But to be honest, Nobody tells us to use WCF specifically. Then why there is roar over WCF? This post will touch the ‘why’ perspective of WCF and in subsequent articles, we will touch base with WCF through coding or programming. What’s the idea behind WCF? Idea behind , can be described as simplified communication between applications or programs written in different languages or residing at different locations. We will try to see two important concepts which are required to understand as How communication between components can be a possibility? Note: Here, component refers to a program or functionality which can exist independently. Remote Procedure Calls (RPC) : As per Wikipedia “a remote procedure call (RPC) is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction” . In Simple words, We have two machines, Server and Client, there is an independent code/program/component available or placed on Server to perform some function. Client like our remote machine is also running a code/program/component, which sends a request to Server to execute program residing on server machine and once execution is over,Server should share the result with program on Client machine who have waited for Server to finish the job. Interfaces: Now we have some idea about RPC, here, we can deduce that Server has to tell the client which all methods are available for use. Now, There is a catch, Server should not expose their methods directly, There should be a level of encapsulation and abstraction applied to protect the functionality. We have interfaces to achieve this kind of feature. Interface ICalls() { public void GetCount(); } An Interface defines the expected behavior and it is available when Server side component implements this interface by inheritance.This interface can only exist if the component is instantiated. This interface is exposed to the client and, As it hides all the complexities of implementation, client just needs to call the method exposed through interface. RPC Calls:                     Client => Interface=>Server All the service oriented technologies like COM,DCOM,Remoting, WebService,WCF were developed on this Model  and can be described as improvised versions of RPC calls via interface. We will try to see the improvements achieved by each of these technologies. 1.COM: Component Object Model- COM can be considered as the...

Read More