Translate

Thursday 23 July 2015

WCF Features

WCF is a Microsoft framework for building Service-Oriented applications.

Features of WCF

  • WCF hosting - If we are working with web services then only option we are having is hosting it inside web server such as IIS using http or wshttp protocols. But WCF supports four types of hosting
    • IIS
    • WAS (Windows process activation services)
    • Self-hosting
    • Windows services
    Message transmission - Messages can be transmitted between clients and service via various transport protocols and encodings such as SOAP using http and binary data using TCP.
  • Serialization - Web services uses XmlSerializer for transferring data between service calls whereas WCF supports multiple serializers
    • DataContractSerializer(faster and supports versioning)
    • NetDataContractSerializer(when it required to include CLR type information in the serialized XML)
    • XmlSerializes(mostly to support backward compatibility).
  • Multiple technologies at one place - WCF unites following four technologies
    • .NET remoting
    • MSMQ
    • Web Services
    • COM+
  • Message Contract - In Web services customizing the headers of the SOAP message was a tedious task. For that we were supposed to derive a class from SoapHeader and then SoapHeaderAttribute is used to indicate the presence of the header.
    But with WCF we can make it easily with the help of simple attributes like MessageContractAttribute, MessageHeaderAttribute, and MessageBodyMemberAttribute.
  • Multiple Message Patterns - WCF supports three message patterns that describe how client and service pass messages
    • Request-Reply Pattern – Client sends message to service and waits for reply.
    • One-Way Message Pattern – Client sends message to service but service does not reply message to client.
    • Duplex pattern – Both client and the service can initiate communication. The client calls a method of the service. The service can then use a client callback to call a method in the client.
  • Security - In WCF security can be implemented with the help of well-known standards such as SSL.
  • Reliable - WCF supports reliable messages with the help of Queues and reliable sessions.
  • REST - WCF can be extended to support plain xml data that is not wrapped in a soap envelope, xml formats such as ATOM and non xml standard such as JSON.
  • WCF Transaction - - WCF supports to create distributed transactions for your service application. Transaction is a collection of logical operations which need to be run as a single logical unit.
    (Either all operations will successfully execute and completes or in case any of them fail others will rollback).
  • WCF instancing - In WCF we can control the way WCF service objects are instantiated in the WCF server. WCF Framework comes up with following instancing models
    • Per Call - A new instance will be created for every client request.
    • Per session - A new instance is created for each new client session and maintained for the lifetime of that session.
    • Single - A single instance handles all client requests for the lifetime of the application.
  • WCF Concurrency - With WCF Concurrency features we can control how service instances can serve multiple requests at the same time. We have three choices
    • Single – Only one request will be served at a time.
    • Multiple - Multiple requests can be handled by the WCF service object at any given moment of time.
    • Reentrant - A single request thread has access to the WCF service object, but the thread can exit the WCF service to call another WCF service or can also call a WCF client through callback and reenter without deadlock.

What is ABC in WCF

We had gone through the feature of WCF and understood why its termed as advanced version of web services. Now it’s time to answer a very basic question related to WCF i.e., what is ABC of WCF?
When we say WCF, we came across end points. Service endpoint can be a part of continuously hosted service hosted in IIS or service hosted in an application.
ABC or Address, Binding and Contract are the three elements which constitutes and Service Endpoint.
  • Address - Where Service is residing (URL of the service.)
  • Binding – How to talk to the service?
  • Example – basicHttpBinding, wsHttpBinding, webHttpBinding etc.
  • Contract – What can the service do for me?