Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

WCF Features

Windows Communication Foundation (WCF) is unified programming model introduced in .Net Framework 3.0. WCF is a combined feature of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.

WCF Features:


With behaviors we can add custom changes; Small changes in the configuration will make your requirements. If extra capability is required, there are a number of entry points that allow you to customize the behavior of a service.

Reliable and Secure:

With WCF you can encrypt messages, you can provide user authentication.
Security can also be implemented using well-known standards such as SSL or WS-SecureConversation.
WCF supports reliable message exchange using reliable sessions implemented over WS-Reliable Messaging and using MSMQ.

Security Authentication Example:

        <binding name="WSHttpBinding_ILeaveSummeryWebService" receiveTimeout="02:50:00"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
            <message clientCredentialType="UserName" algorithmSuite="xyztestName256" />


WCF supports transactions, it uses below three models for transactions:
1.  WS-AtomicTtransactions 
2.  System.Transactions namespace
3.  Microsoft Distributed Transaction Coordinator

Service Orientation:

WCF provides great feature to build loosely coupled application called service oriented application. The services have the general advantage of being loosely-coupled instead of hard-coded from one application to another.

Exception Handling:

Exception handling in WCF is performed with following :

a.  Using fault contracts
b.  Directly handling the exception thrown.
c.  Implementing the IErrorHandler interface
d.  Handling ServiceHost events

Durable, Reliable and Queued Messages:

WCF ensures durable message communication, it uses database to save messages with durable message pattern if any disruption occurs messages are saved in database.

Service Metadata:

WCF supports publishing service metadata using best industry standards such as WSDL, XML Schema and WS-Policy.


WCF implements modern industry standards for Web service interoperability.

Multiple Message Patterns :

Messages are exchanged in one of several patterns. The most common pattern is the request/reply pattern, where one endpoint requests data from a second endpoint.

REST Web service and AJAX support:

Presently WCF supports REST web services and also AJAX. WCF can be configured to process "plain" XML data that is not wrapped in a SOAP envelope.

WCF Endpoints

Each end point is medium to communicate with external world. All communication with WCF service occurs through the endpoints of the service.

Each END point consist four properties:

1.  Address (Where)   2.  Binding (How)   3. Contract (What)   4. Behavior (Custom Changes)


Simply tells external world where service located. The URL specifies where this WCF service is hosted .Client will use this URL to connect to the service.
Example: http://localhost/EmployeeLeavesService/LeaveSummery.svc


Binding explains how client communicate with WCF service. There are different protocols used in binding, you can use any protocol according to your WCF service requirement.



Classic(Basic before WCF) web service,No security by default


With WS-* support. Supports Security,transactions


With duplex contract and transaction support


With federated security. Supports transactions


Communication directly with MSMQ applications. Supports transactions


Communication between WCF applications by using queuing. Supports transactions


Communication between WCF applications on same computer. Supports duplex contracts and transactions


Communication between computers across peer-to-peer services. Supports duplex contracts


Communication between WCF applications across computers. Supports duplex contracts and transactions

Binding Example:

Basic HTTP:

  <binding name="BasicHttpBinding_ILeaveSummeryWebService" receiveTimeout="02:50:00" maxReceivedMessageSize="2147483647" />




        <binding name="WSHttpBinding_ILeaveSummeryWebService" receiveTimeout="02:50:00"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" algorithmSuite="xyztestName256" />


A contract that specifies what operations available, operations specifies what endpoint will communicate with external world.
<endpoint contract="ILeaveSummeryWebService" binding="wsHttpBinding" bindingConfiguration="WsHttpBinding_ILeaveSummeryWebService" address="http://localhost/EmployeeLeavesService/LeaveSummery.svc" />


A set of behaviors that specify local implementation details of the endpoint.

        <behavior name=" EmployeeLeavesWebServiceBehaviour">
          <!--Set this to a high value in order to be able to serialize many objects--> 
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="false" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug httpHelpPageEnabled="false" includeExceptionDetailInFaults="true" />
                <userNameAuthentication userNamePasswordValidationMode="Custom"
                                        customUserNamePasswordValidatorType="EmployeeLeavesService.LeaveCustomUserNameValidator, EmployeeLeavesService" />

Windows Communication Foundation (WCF)

Windows Communication Foundation (WCF) is a framework in Microsoft .Net for building connected, service-oriented applications.


Using WCF web service, you can send data as asynchronous messages from one service endpoint to another.  It is unified programming model introduced in .Net Framework 3.0. WCF is a combined feature of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.

ABC of WCF (Address, Binding, Contract):

Address: where this WCF service is hosted .Client will use this URL to connect to the service.
Binding: how client communicate with WCF service.
Contract: what operations available in WCF service.  

Some advantages using WCF service over Classic ASMX web services:

a. WCF services provide better reliability and security in compared to ASMX web services.
b. Provides transaction feature.
c. Small changes in the configuration will meet your requirements.
d. Support hosting in IIS,WAS(Windows activation service),Self hosting, Windows Service.
e. Support different types of bindings((TCP/IP, HTTP,HTTPS , PIPE, MSMQ etc.).
f. Better Exception handling.
g . Supports multi-threading by using ServiceBehaviour class.
h. Improved performance compared to ASMX web services.