Skip to main content

Windows Communication Foundation - overview

WCF is a framework ( yep another framework :D ). It is a unified programming model for building service oriented applications
 
The WCF architecture uses message-based communication. This involves messages being sent between endpoints generated by either a service or a client.


A service is an application that responds to a request, and a client is an application that initiates a request. In many cases, a single application can act as both a client and a service, depending on the situation.





WCF is implemented primarily as a set of classes on top of the .NET Framework’s Common Language Runtime (CLR). Because it extends their familiar environment, WCF allows .NET developers to build service-oriented applications in a familiar way.


The benefits of WCF
  • asynchronous one-way messaging Many applications use asynchronous one-way messaging. For example, web browsers send requests to web servers and wait for replies. WCF supports asynchronous one-way messaging, which provides advanced functionality, reliability, and application responsiveness. It also makes efficient use of available processing power. Asynchronous messaging is the most efficient way of performing the input and output tasks required by a distributed application.
  • Support for cross-vendor interoperability, including  security, and transactions.  WCF has interoperability features that were previously spread across different technologies. It communicates using SOAP-based web services (WS-*) and supports Representational State Transfer (REST) architectures, Plan Old XML (POX) messaging systems, and JavaScript Object Notation (JSON) data during WCF runtimes. In addition, you can write custom extensions that enable WCF applications to communicate with applications that require proprietary message encodings.
    WCF allows transactional scopes to flow across multiple applications
    Because WCF adheres to the WS-Security specifications, its default security options range from message-based security to the more traditional transport-centric security model.
  • reliability:WCF provides four assurances for reliability for distributed computing – at most once, at least once, exactly once, and in order. An assurance is similar to a guarantee. It contains mechanisms that provide these assurances with little or no modification to the application. As opposed to traditional types of assurances, WCF's assurance mechanisms don't depend on the transport method used.  
  • platform consolidation
WCF unifies the following distributed communication technologies


ASP.NET Web Services (ASMX) and the Web Service Enhancements (WSE): The ASMX and WSE technologies provide an interoperable, service-oriented infrastructure and programming model that can easily be integrated into web services or web service clients. They work on HTTP only and can have performance issues but are interoperable because their data is encoded using XML.
Enterprise Services: Enterprise Services is a component-oriented technology that provides transaction integration across multiple objects performing related work in a distributed environment. It minimizes throttling, optimizes pooling of object instances, provides a publish/subscribe mechanism for events, and uses a fast, secure, and platform-integrated transport method. However, Enterprise Services provides poor interoperability, because it is tightly coupled with the infrastructure.
Microsoft Message Queue (MSMQ): MSMQ is a set of objects that provide a durable, volatile, and scalable message queuing system that ensures reliable data transport from one place to the next. It is used to collect a group of messages, send them to a server for processing, and receive a reply from the server. However, MSMQ cannot process corrupted messages efficiently. When a corrupted message is received by the server, it blocks other messages in the queue.
Remoting: Remoting is the application programming interface (API) used by .NET to allow .NET Framework applications to communicate across application domain boundaries. It is a very flexible and extensible model that enables developers to manipulate proxy mechanisms, transports, and the way communication channels function. However, Remoting does not provide interoperability with non-.NET applications.  


  • Explicit support for service-oriented development.
explicit boundaries WCF services function using defined interfaces to identify the communications that flow outside the boundaries of the service.
independent services All WCF services are deployed and managed independently; they are independent of deployment, installation, and version issues. Also, each service interaction is independent of other interactions.
schema and contract-based communication WCF services communicate with clients by providing only the schema of the message and not its implementation classes. This helps developers change the service implementation in the future without impacting the clients.
policy-based compatibility Compatibility between WCF services and clients at run time is determined using published policies. Policies help separate the description of the service from its implementation details.


The SOA-based WCF architecture contains four layers – Contracts, Service Runtime, Messaging, and Hosting.  


Contracts: The Contracts layer describes the WCF message system.
They are of two types- Data & Service
  • A Service Contract describes the method signatures of a service. It's defined using programming languages, such as Visual Basic and Visual C#.  
  • A Data Contract enables .NET types to be expressed in XML.
  • Message Contracts define the structure of SOAP messages exchanged between a service and a client, and they allow you to view or modify messages.  
  • Policies and Bindings
  • Policies and Bindings define the configuration, such as security levels, required by clients to communicate with a service.


A practical experience
Last year i was associated with a project (.Net 2.0) which had both Java & .net modules interacting with each other. More over there were custom adapters/interfaces (in C#) for around 500 external devices which interected with our application. Few devices provided the data for our application and few others were dependant on the data generated by our application. A specific set of meesages were send  to MSMQ for other devices to read. It was a distirbution nightmare. We had web services. custom adapters, MSMQ, remoting almost all the distributed technologies supported by Microsoft in one project. Initially we had a very difficult time managing all these.


We migrated the project to .Net 3.5. To solve this distribution nightmare we adopted WCF. The following factors helped us to choose WCF
  • Because WCF can communicate using Web services, interoperability with other platforms that also support SOAP, such as the leading J2EE-based application servers, is straightforward.(We can also configure and extend WCF to communicate with Web services using messages not based on SOAP, for example, simple XML formats like RSS)
  • Managing object lifetimes, defining distributed transactions, and other aspects of Enterprise Services are now provided by WCF. They are available to any WCF-based application, which means that the our application can use them with any of the other applications it communicates with.
  • The WCF option for queued messaging, built on Message Queuing, allows applications to use persistent queuing without using another set of application programming interfaces.
  • Performance is of paramount concern for most businesses. WCF is developed with the goal of being one of the fastest distributed application platform developed by Microsoft. (To allow optimal performance when both parties in a communication are built on WCF, the wire encoding can be used, in this case is an optimized binary version of an XML Information Set. Messages still conform to the data structure of a SOAP message, but their encoding uses a binary representation of that data structure rather than the standard angle-brackets-and-text format of the XML 1.0 text encoding.)

Comments

Popular posts from this blog

PDCA & SCRUM (or Agile); Why is it important?

The PDCA (Plan DO Check Act) cycle was made popular by Dr. W. Edwards Deming. This is a scientific cyclic process which can be used to improve the process (or product). This is cyclic in nature and usually time boxed. Plan  This is the first stage of the process. During this step the team discusses the objectives, the process and the clear conditions of exit (conditions of acceptance). This stage sets the measurable and achievable goals for the team. DO Team works together to achieve the objective set in the planning phase. Team works with the set of agreed process. Check Once the implantation is done team regroups and verifies the output and compares it to the agreed conditions of acceptance decided during the planning phase. The deviation, if any, is noted down. ACT If any deviation in planned tasks is observed during the Check stage, a root cause analysis is conducted. Team brainstorms and identifies the changes required to prevent such deviations in future. Team also

Why is potentially shippable product quality important

Agile teams work in iterations. During this period, they are supposed to work on product increments which can be “delivered” at the end of iteration. But how you know that the correct product was delivered? Many teams have different kinds of acceptance criteria and Definition of Done (DoD). But in many cases, this “done” is not the real “done” there might be some testing pending, some integration or review pending or anything else which prevents the actual use of the product increment. Many of these teams will need additional iterations to finish hardening their products. Many teams will implement different types of “gates” or approval steps to move to next stage. The free flow of product will be interrupted. They might end up doing mini waterfall within their agile process. Many don’t even realize this. This results in poor quality and requires additional effort to “harden” the product. Potentially Shippable Product increment The acceptance criteria and DoD should be modified

Product Backlog: Should you write everything in user story format?

I like user stories a lot. They help everyone talk the same language and results in a better product. User story alone does not constitute product requirement. User story is supposed to be a place holder for discussion which should happen between the team, Product Owner and the customer. This discussion result in a common understanding which along with the user story content is the product requirement. This format captures the essence of requirement without confusing the readers User Story is only one of the many different ways in which requirements can be represented. This is not mandatory in any Agile “process”. But many have made this mandatory. I have seen many spending countless hours trying to write the requirements in user story format when they could have easily written that in simple one-line sentence in few minutes.   I have seen team members refusing to even discuss the requirement until product owner rewrote the requirement in user story format. Once I