WCF

ABCs of WCF


WCFABC

ABC is the three building blocks of WCF and they are known as

A – Address (Where) : Address tells us where to find the services, like url

B – Bindings (How) : Bindings tells us how to find the services or using which protocols finds the services (SOAP, HTTP, TCP etc.) . Read more about Different Types Of Binding In WCF

.C – Contacts (What) : Contracts are an agreement between the consumer and the service providers that explains what parameters the service expects and what return values it gives.

WCF Different Types Of Bindings In WCF


What Is Binding In WCF?

Binding describes how a client is going to communicate to WCF service. Binding is used as per client need. It supports different types of protocol to communicate with client and different types of encoding to transfer the data over the internet. So, basically binding is nothing but it is a way of communication between client and service as per client need.

Binding

  • Describes how a service communicates
  • Specifies which protocol to be used
  • Specifies the encoding method to format the message contents
  • Specifies the security requirements
  • Specifies the message exchange format
  • Specifies the message session mode

There are different types of bindings available in WCF.

Binding Names Transposrt Encoding Interoperable
BasicHttpBinding HTTP/HTTPS Text/MTOM YES
NetTcpBinding TCP Binary NO
NetPeerBinding P2P Binary NO
NetNamedPipeBinding IPC Binary NO
WSHttpBinding HTTP/HTTPS Text/MTOM YES
WSFederationHttpBinding HTTP/HTTPS Text/MTOM YES
WSDualHttpBinding HTTP Text/MTOM YES
NetMsmqBinding MSMQ Binary NO
MsmqIntegrationBinding MSMQ Binary YES

(more…)

WCF – Architecture


wcf_architectureWCF has a layered architecture that offers ample support for developing various distributed applications. The architecture is explained below in detail.

(more…)

Developers Tools for WCF


For developing a WCF service application, there are mainly two tools – Microsoft Visual Studio and CodePlex. Microsoft Visual Studio is a complete package of development tools, necessary for developing a large number of diverse applications like ASP.NET web applications, desktop applications, mobile applications, and many more.

Microsoft Visual Studio uses the .NET framework functionality. CodePlex on the other hand is an open-source project hosting site of Microsoft that offers several free tools for WCF service application development.

Microsoft Visual Studio

There are many editions of Microsoft Visual Studio and initially it (Visual Studio 2005) was not an ardent supporter of WCF development. At present, Visual Studio 2008 is the only Microsoft IDE available for the development of WCF service applications.

Nowadays, the latest version of Microsoft Visual Studio 2010 is also a preferred tool for developing WCF service application. There is also a readymade template in Visual Studio for developing WCF service application.

Selection of such a template leads to addition of files for the following purposes:

  • Service contract
  • Service implementation
  • Service configuration

Requisite attributes get added automatically and a simple “Hello World” service gets created by Microsoft Visual Studio without even writing any code.

(more…)

Differences between WCF and a Web service


There are some major differences that exist between WCF and a Web service which are listed below.

  • Attributes – WCF service is defined by ServiceContract and OperationContract attributes, whereas a web service is defined by WebService and WebMethod attributes.
  • Protocols – WCF supports a range of protocols, i.e., HTTP, Named Pipes, TCP, and MSMQ, whereas a web service only supports HTTP protocol.
  • Hosting Mechanisms – Various activation mechanisms are there for WCF hosting, i.e., IIS (Internet Information Service), WAS (Windows Activation Service), Self-hosting and Windows Service, but a web service is hosted only by IIS.
  • Services – WCF supports a robust security, trustworthy messaging, transaction and interoperability, while a web service only supports security services.
  • Serializer – WCF Supports DataContract serializer by employing System.Runtime.Serialization, whereas a web service supports XML serializer by making use of System.Xml.Serialization.
  • Tools – ServiceMetadata tool (svcutil.exe) is used for client generation for a WCF service, while WSDL.EXE tool is used for generating the same for a web service.
  • Exception Handling – In WCF, unhandled exceptions are handled in a better way by making use of FaultContract. They do not return to the client like in a web service as SOAP faults.
  • Hash Table – It is possible to serialize a Hash Table in WCF, but this is not the case in a web service.
  • Bindings – WCF supports several types of bindings like BasicHttpBinding, WSDualHttpBinding, WSHttpBinding, etc., while a web service supports only SOAP or XML.
  • Multithreading – WCF supports multithreading by using the ServiceBehavior Class, whereas this is not supported in a web service.
  • Duplex Service Operations – WCF supports duplex service operations apart from supporting one-way and request-response service operations, whereas a web service does not support duplex service operations.

Overview Of WCF


78a0313b-286b-4525-a881-8dc2aa167f3e_WCF_logoWCF stands for Windows Communication Foundation. The elementary feature of WCF is interoperability. It is one of the latest technologies of Microsoft that is used to build service-oriented applications. Based on the concept of message-based communication, in which an HTTP request is represented uniformly, WCF makes it possible to have a unified API irrespective of diverse transport mechanisms.

WCF was released for the first time in 2006 as a part of the .NET framework with Windows Vista, and then got updated several times. WCF 4.5 is the most recent version that is now widely used.

A WCF application consists of three components:

  • WCF service,
  • WCF service host, and
  • WCF service client.

WCF platform is also known as the Service Model.

Fundamental Concepts of WCF

Message

This is a communication unit that comprises of several parts apart from the body. Message instances are sent as well as received for all types of communication between the client and the service.

(more…)