What Message Exchange Patterns (MEPs) supported by WCF?

Three MEP supported by WCF.
1. Request/Response
2. One Way
3. Duplex

Request/Response

It’s the default pattern. In this pattern, a response message will always be generated to consumer when the operation is called, even with the void return type. In this scenario, response will have empty SOAP body.

One Way

In some cases, we are interested to send a message to service in order to execute certain business functionality but not interested in receiving anything back. OneWay MEP will work in such scenarios. If we want queued message delivery, OneWay is the only available option.

Duplex

The Duplex MEP is basically a two-way message channel. In some cases, we want to send a message to service to initiate some longer-running processing and require a notification back from service in order to confirm that the requested process has been completed.

How we can achieve Operation Overloading while exposing WCF Services?

By default, WSDL doesn’t support operation overloading. Overloading behavior can be achieved by using “Name” property of OperationContract attribute.

[ServiceContract]
interface IMyCalc
{
[OperationContract(Name = "SumInt")]
int Sum(int arg1,int arg2);

[OperationContract(Name = "SumDouble")]
double Sum(double arg1,double arg2);
}

When the proxy will be generated for these operations, it will have 2 methods with different names i.e. SumInt and SumDouble.

What are the possible ways of hosting a WCF service?

To host WCF service, you need at least a managed process, a ServiceHost instance and an Endpoint configured.

Possible approaches for hosting a service are:

  • Hosting in a Managed Application/ Self Hosting
  1. Console Application
  2. Windows Application
  3. Windows Service
  • Hosting on Web Server
  1. IIS 6.0 ( ASP.NET application supports only HTTP )
  2. Windows Process Activation Service (WAS) i.e. IIS 7.0 supports HTTP, TCP/IP, NamedPipes, MSMQ

What are WCF Service End points?

For WCF services to be consumed, than it must be exposed; Clients need information about service to communicate with it. This is where service endpoints play their role.

WCF service endpoint has three basic elements i.e. Address, Binding and Contract.

  • Address: It defines “WHERE”. Address is the URL that identifies the location of the service.
  • Binding: It defines “HOW”. Binding defines how the service can be accessed.
  • Contract: It defines “WHAT”. Contract identifies what is exposed by the service.

What is the difference between WCF and ASMX Web Services?

Basic difference between ASMX or ASP.NET is web service designed to send and receive messages using SOAP over HTTP.

WCF can exchange messages using any format (SOAP is default) over any transport protocol such as HTTP, TCP/IP, MSMQ, NamedPipes etc.

What is Windows communication foundation, WCF?

WCF is a framework that builds applications that can inter-communicate based on service oriented architecture consuming secure and reliable web services. This also helps in Distributed computing. The WCF also brings together the various communication models into a single model.

In which scenario WCF data services provides better result ?

You can select WCF data services when you

  • Want to implement the Data layer.
  • Want to access it from javascript.
  • Want to connect with database server by using HTTP protocol.