Dot Net 4.0 – Windows Communication Foundation (WCF)

Windows Communication Foundation (WCF)

It is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. There are many other such technologies, including the Component Object Model and Distributed Component Object Model, Remote Method Invocation, Microsoft Message Queuing (MSMQ), and WebSphere MQ.

A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data. A few sample scenarios include:

  • A secure service to process business transactions.
  • A service that supplies current data to others, such as a traffic report or other monitoring service.
  • A chat service that allows two people to communicate or exchange data in real time.
  • A dashboard application that polls one or more services for data and presents it in a logical presentation.
  • Exposing a workflow implemented using Windows Workflow Foundation as a WCF service.
  • A Silverlight application to poll a service for the latest data feeds.

While creating such applications was possible prior to the existence of WCF, WCF makes the development of endpoints easier than ever. In summary, WCF is designed to offer a manageable approach to creating Web services and Web service clients.

We develop WCF as contracts, interface, operations, and data contracts. As the developer we are more focused on the business logic services and need not worry about channel stack. WCF is a unified programming API for any kind of services so we create the service and use configuration information to set up the communication mechanism like HTTP/TCP/MSMQ etc

  • ASMX is IIS and HTTP only – WCF gives you HTTP, NetTcp, MSMQ, IPC – you name it

you can write your service once, and expose it on multiple endpoints

  • self-hosting: you can host your WCF service in a console app, a Winforms app, a WPF app, or let it be handled by IIS/WAS
  • a lot more options like reliable sessions, lot more security options
  • you don’t have to deal with as much in WCF as you do in ASMX – you can concentrate on your business problem, and let the config and attributes handle all the stuff you don’t want to deal with.

ASMX is:

  • easy and simple to write and configure
  • only available in IIS
  • only callable from HTTP

WCF can be:

  • hosted in IIS, a Windows Service, a Winforms application, a console app – you have total freedom
  • used with HTTP (REST and SOAP), TCP/IP, MSMQ and many more protocols

1)Web services can only be invoked by HTTP (traditional webservice with .asmx). While WCF Service or a WCF component can be invoked by any protocol (like http, tcp etc.) and any transport type.

2) web services are not flexible. However, WCF Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends.

What Does WCF replace

ASMX, WSE, .NET REMOTING, COM+, MSMQ.

Rather than requiring different technologies for different communication styles, WCF provides a single unified solution.

1) Component Object Model (COM) It is used to enable interprocess communication and dynamic object creation in a large range of programming languages.

2) Distributed Component Object Model (DCOM) communication among software components distributed across networked computers.

3) MSMQ is essentially a messaging protocol that allows applications running on separate servers/processes to communicate in a failsafe manner.

4) WebSphere MQ is the most popular system for messaging across multiple platforms, including Windows, Linux, OS/2, IBM mainframe and midrange, and Unix. WebSphere MQ is often referred to as “MQ” or “MQ Series”.

5) Web Services Enhancements for .NET (WSE) is a product that enables you to build secure Web services quickly and easily.

6) .NET remoting enables you to build widely distributed applications easily, whether application components are all on one computer or spread out across the entire world

Architecture

WCF is meant for design and deploying distributed applications under SOA (Service Oriented Architecture) implementation.

WCF is designed in accordance with service oriented architecture principles to support distributed computing where services are consumed by consumers. Clients can consume multiple services and services can be consumed by multiple clients. Services are loosely coupled to each other. Services typically have a WSDL interface (Web Services Description Language) that any WCF client can use to consume the service, irrespective of which platform the service is hosted on. WCF implements many advanced Web services (WS) standards such as WS-AddressingWS-Reliable Messaging and WS-Security. With the release of .NET Framework 4.0, WCF also provides RSS Syndication Services.

Endpoints

A WCF client connects to a WCF service via an Endpoint. Each service exposes its contract via one or more endpoints. An endpoint has an address, which is a URL specifying where the endpoint can be accessed, and binding properties that specify how the data will be transferred.

The mnemonic “ABC” can be used to remember address/binding[disambiguation needed]Contract. Binding specifies what communication protocols are used to access the service, whether security mechanisms are to be used, and the like. WCF includes predefined bindings for most common communication protocols such as SOAP over HTTP, SOAP over TCP, and SOAP over Message Queues, etc. Interaction between WCF endpoint and client is done using a SOAP envelope. SOAP envelopes are in simple XML form that makes WCF platform independent.

When a client wants to access the service via an endpoint, it not only needs to know the contract, but it also has to adhere to the binding specified by the endpoint. Thus, both client and server must have compatible endpoints.

With the release of the .NET Framework 3.5 in November 2007, Microsoft released an encoder that added support for the JSON serialization format to WCF.[1] This allows WCF service endpoints to service requests from AJAX-powered Web pages.

APPLICATION

The rental car reservation application provides WCF-based services that can be accessed by various clients.

Unification of Microsoft’s Distributed Computing Technologies

Think about the team of developers implementing the rental car reservation application described earlier. In the world before WCF, this team would need to choose the right distributed technology from the multiple choices originally offered by the .NET Framework. Yet given the diverse requirements of this application, no single technology would fit the bill. Instead, the application would probably use several of these older .NET technologies. For example:

1)  ASMX, also called ASP.NET Web Services, would be an option for communicating with the Java EE-based reservation application and with the partner applications across the Internet. Given that Web services are widely supported today, this would likely be the most direct way to achieve cross-vendor interoperability.

2) .NET Remoting is a natural choice for communication with the call center application, since both are built on the .NET Framework. Remoting is designed expressly for .NET-to-.NET communication, so it would offer the best performance for this situation.

3) Enterprise Services might be used by the rental car reservation application for things such as managing object lifetimes and defining distributed transactions. These functions could be useful in communicating with any of the other applications in this scenario, but Enterprise Services supports only a limited set of communication protocols.

4) Web Services Enhancements (WSE) might be used along with ASMX to communicate with the Java EE-based reservation application and with the partner applications. Because it implements more advanced SOAP-based standards, known collectively as the WS-* specifications, WSE can allow better security and more, as long as all applications involved support compatible versions of these specifications.

5) System.Messaging, which provides a programming interface to Microsoft Message Queuing (MSMQ), could be used to communicate with Windows-based partner applications that weren’t always available. The persistent queuing that MSMQ provides is typically the best solution for intermittently connected applications.

6) System.Net might be used to communicate with partner applications or perhaps in other ways. Using this approach, developers can create applications that use the HTTP-based communication style known as Representational State Transfer (REST).

If it were built on an earlier version of the .NET Framework, the rental car reservation application would need to use more than one of these communication technologies, and maybe even all of them, to meet its requirements. Although this is technically possible, the resulting application would be complex to implement and challenging to maintain. A better solution is needed.

WS – Protocol Support

Security, Reliable Messaging, Transactions, Metadata, Messaging, XML.

Where it can be used

business-to-business (B2B)
business-to-consumer (B2C),
Interoperability with other platforms and technologies
messaging for any kind of communication
Routing
and for all the kind of services that were earlier developed using ASMX, WSE, Web Services, MSMQ, and distributed stack. It also helps in creating the distributed application in a very easy manner that earlier would have involved the usage of two or more distributed technology. These custom solution were earlier not possible to develop in either web services or .NET Remoting. WCF facilitates in building these custom solutions. WCF provides a Uniform programming model to creating distributed applications and has been designed to support  Service orientation… many more

Performance Characteristics

In most cases these can be used but might change according to the requirement.

Note : This article is written taking reference from msdn and other standard microsoft sites just to give a clear Idea how this technology works i have compiled into one, also my personal views are written this should not be taken for granted.

Reference : Dilip Kumar Jena ( http://mstechexplore.wordpress.com )

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s