WCF Interview Questions and Answers (209) - Page 3

What is ABC of WCF?

ABC is the three building blocks of WCF and they are known as

A - Address (Where): Address tells us where to find the services, like url

B - Bindings (How) : Bindings tells us how to find the services or using which protocols finds the services (SOAP, HTTP, TCT etc.)

C - Contacts (What): Contracts are an agreement between the consumer and the service providers that explains what parameters the service expects and what return values it gives.

Hope this will be very helpful to understand three building blocks of WCF, a very frequently asked interview questions.
How the concurrency mode is specified in WCF service?


The concurrency mode is specified using the ServiceBehavior attribute on the class that implements the service.

Public class ServiceClass : IServiceInterface{
//Implementation Code

There are 3 possible values of ConcurrencyMode enumeration

Which are the 3 types of transactions manager WCF supports?


WCF supports following 3 types of transactions managers:

a. LightWeight
b. OLE Transactions
c. WS-Atomic Transactions

Which bindings in WCF support the message streaming?


Following bindings supports the streaming in WCF:

1. basicHttpBinding
2. netTcpBinding
3. netNamedPipeBinding

How to set the instancing mode in WCF service?

In WCF, instancing mode is set at service level. For ex.

//Setting PerSession instance mode
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
class MyService : IMyService
//Implementation goes there
What is Address Header in WCF?

Address Header contains the information which is sent with every request, it can be used by either end point service or any intermediate device for determining any routing logic or processing logic.

WCF provides AddressHeader class for this purpose.

Example :

AddressHeader addressHeader= AddressHeader.CreateAddressHeader("Name of the header", "Information included in header ");

Once the AddressHeader instance is created, it can be associated with end point instance as follows :
EndpointAddress endpoint = new EndpointAddress(new Uri("http://myserver/myservice"), addressHeader);

In WCF which bindings supports the reliable session?

In WCF, following bindings supports the reliable session

1. wsHttpBinding
2. wsDualHttpBinding
3. wsFederationHttpBinding
4. netTcpBinding

What are tha advantages of hosting WCF service in WAS?

WAS (Windows Activation Service) is a component of IIS 7.0. Following are few advantages :

1. We are not only limited to HTTP protocol. We can also use supported protocols like TCP, named pipes and MSMQ

2. No need to completely install IIS. We can only install WAS component and keep away the WebServer.

What is service host factory in WCF?

1. Service host factory is the mechanism by which we can create the instances of service host dynamically as the request comes in.

2. This is useful when we need to implement the event handlers for opening and closing the service.

3. WCF provides ServiceFactory class for this purpose.

What are the different platforms where we can host WCF service ?

WCF Services can be hosted on following platforms

1. WAS(Windows Activation Service)

2. Self Hosting

3. IIS
What are the different WCF binding available?

• BasicHttpBinding
• WSHttpBinding
• WSDualHttpBinding
• WSFederationHttpBinding
• NetTcpBinding
• NetNamedPipeBinding
• NetMsmqBinding
• NetPeerTcpBinding
• MsmqIntegrationBinding
Advantages of Hosting WCF in IIS

1. Provides process activation and recycling ability thereby increasing reliability
2. It is a simplified way of deployment and development of hosted services.
3. Hosting WCF services in IIS can take advantage of scalability and density features of ASP.NET
Can we overload methods in WCF Service or Web Service?

Yes for a WCF Service use the Name property of OperationContractAttribute class
interface ddd


[OperationContract(Name = "one")]

int calc(int a,int b);

[OperationContract(Name = "two")]

double calc(double a,double b);


1)For a Web Service use the MessageName property of WebMethodAttribute class

2)Please comment the following line in the .cs file of the Web Service

//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public string HelloWorld(string a) {
return "Hello"+" "+a;
public string HelloWorld()
return "Hello second";
What does a Windows Communication Foundation, or WCF, service application use to present exception information to clients by default?

However, the service cannot return a .NET exception to the client. The WCF service and the client communicate by passing SOAP messages. If an exception occurs, the WCF runtime serializes the exception into XML and passes that to the client.
What is the use of Is Required Property in Data Contracts?

Data Contracts, is used to define Required or NonRequired data members. It can be done with a property named IsRequired on DataMember attribute.

public class test
public string NameIsMust;

public string Phone;

What happens if we apply DataMember attributes to Static Fields?

NOTE: This is objective type question, Please click question title for correct answer.
What is data contract equivalence?

Two data contracts are said to be equivalent, if they satisfy the following conditions.
- Both the datacontracts must have same namespace
- Both the datacontracts must have same name
- The data member on data contract must have an equivalent data member on the other.
- The members in the datacontract must appear in the same order in both datacontracts.


The following two data contracts are equal.

public class Person
public string Name;

public string Email_ID;

[DataContract(Name = "Person")]
public class Employee
[DataMember(Name = "Name")]
private string EmpName;

private string address;

[DataMember(Name = "Email_ID")]
private string EmpEmailId;

Which of the following statements are true?

NOTE: This is objective type question, Please click question title for correct answer.
How do we customize Data Contract Names for Generics types?

We can customize the generic datacontract names by allowing parameters. Find the Example below

[DataContract(Name = "Shape_{1}_brush_and_{0}_shape")]
public class Shape< Square,RedBrush>
// Code not shown.

Here, the Data Contract Name is "Shape_RedBrush_brush_and_Square_shape”
{0} – First Parameter in the generic type.
{1}- Second Parameter in the generic type.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories