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
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.
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