Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is WCF so important and in what cases is it used?

Tags:

wcf

I understand to an extent that it helps applications communicate regardless of their location. Why is it important and what is an example of a real-world use of WCF?

like image 829
simplyme Avatar asked Mar 04 '09 15:03

simplyme


People also ask

What is WCF and why it is used?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.

Why should I use WCF?

WCF is useful when building applications or services that need to communicate with each other. You can use WCF to easily build programs that communicate, whether it's across processes, across servers, or across the world.

Is WCF used now?

NET Framework technologies, your WCF applications will continue to work for a long time. In fact, WCF will likely work for the next two decades thanks to . NET Framework being considered part of the windows operating system.

What is WPF and WCF in .NET explain with an example?

WCF = Windows COMMUNICATION Foundation. WPF = Windows PRESENTATION Foundation. WCF deals with communication (in simple terms - sending and receiving data as well as formatting and serialization involved), WPF deals with presentation (UI)


2 Answers

WCF is a generic communication mechanism that allows you to setup generic client/host communication between two parties. The neat thing about WCF is that is allows you to configure service properties such as transport (http/pipes/tcp/Tibco EMS), security models (any of the W3C standards), compression, encoding, timeouts, etc, without changing ANY code. That is powerful. Best of all, you can configure it so that you can have a service in C# and a client in Java (or any other language or the other way around), as long as they both talk using the same mechanisms.

You can create a standard HTTP SOAP web service using WCF and one day decide to switch it to use the faster named pipes for local communication. You can create web services that talk over TibcoEMS and have easy failover on the queue level. You can create a file streaming web service that distributes all kinds of images/videos to your application.

like image 140
Szymon Rozga Avatar answered Oct 19 '22 07:10

Szymon Rozga


Here Are some brain dump i think might be useful to understand the whole scenario.

Reason of Creating WCF : Background

Modern Application[Distributed Application] development we use different architechtures and technologies for communication

i.e:

  • COM+
  • .NET Enterprise Services
  • MSMQ
  • .NET Remoting
  • Web Services

As there are various technologies. they all have different architechtures. so learning all them are tricky and tedious.

one need to focus on each technologies to develop rather than the application business logic

so microsoft unifies the capabilities into single, common, general service oriented programming model for Communication. WCF provides a common approach using a common API which developers can focus on their application rather than on communication protocol.

Now-a-days we call it WCF.

WCF Background

N.B: image collected from - http://www.codeproject.com/Articles/255114/Windows-Communication-Foundation-Basics


What Exactly WCF Service Stands For?

WCF lets you asynchronus messages transform one service endpoint to another.

The Message Can be simple as

  • A Single Character
  • A word

sent as XML

  • complex data structure as a stream of binary data

Windows Communication Foundation(WCF) supports multiple language & platforms.

WCF Provides you a runtime environment for your services enabling you to expose CLR types as Services and to consume other Services as CLR Types.


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.

Why on Earth We Should Use WCF?

from a Code Project Article, thanks to @Mehta Priya I found the following Scenarios to illustrate the concept. Let us consider two Scenario:

  • The first client is using java App to interact with our Service. So for interoperability this client wants the messages in XML format and the Protocol to be HTTP.
  • The Second client uses .NET so far better performance this clients wants messages in binary format and the protocol to be TCP.

Without WCF Services

now for the stated scenarios if we don't use WCF then what will happen let's see with the following images:

  • Scenario 1 :

interoperability without WCF

  • Scenario 2:

interoperability without WCF

These are two different technologies and have completely differently programming models. So the developers have to learn different technologies

so to unify & bring all technologies under one roof. Microsoft has come with a new programming model called WCF.

How WCF Make things easy ?

one implement a service and he/she can configure as many end points as it required to support all the client needs .

To support the above 2 client requirements -we would configure 2 end points -we can specify the protocols and message formats that we want to use in the end point of configuration

interoperability without WCF

References:

  1. WCF : What , Why and When https://vishalnayan.wordpress.com/2010/12/31/wcf-what-why-when/
  2. Why we use WCF Service? http://www.codeproject.com/Tips/815742/Why-We-Use-WCF-Service-and-Sample-of-WCF-Service
  3. What Is Windows Communication Foundation https://msdn.microsoft.com/en-us/library/ms731082(v=vs.110).aspx
  4. Windows Communication Foundation Basics http://www.codeproject.com/Articles/255114/Windows-Communication-Foundation-Basics
like image 34
alamin Avatar answered Oct 19 '22 09:10

alamin