Top 10 WCF Interview Questions – Easy WCF
Skip to content

Top 10 WCF Interview Questions

Top 10 WCF Interview Questions:

1.What is the difference between WCF and ASMX Web Services?
2.What are WCF Service Endpoints? Explain.
3.What are Contracts in WCF?
4.What is Binding and explain different bindings in WCF?
5.What are the possible ways of hosting a WCF service? Explain.
6.How we can achieve Operation Overloading while exposing WCF Services?
7.What Message Exchange Patterns (MEPs) supported by WCF? Explain each of them briefly.
8.What is DataContractSerializer and How its different from XmlSerializer?
9.Please explain briefly different Instance Modes in WCF?
10.Please explain different modes of security in WCF? Or Explain the difference between Transport and Message Level Security.

 

1.What is the difference between WCF and ASMX Web Services?

Simple and basic difference is that ASMX web service is designed to send and receive messages using SOAP over HTTP only. While WCF service can exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, NamedPipes etc)

WCF vs ASMX service

You can read more detailed difference here.

 

2.What are WCF Service Endpoints? Explain.

The endpoint is the fusion of the address, contract, and binding. Every endpoint must have all three elements, and the host exposes the endpoint.

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

 

3.What are Contracts in WCF?

In WCF, all services expose contracts.

The contract is a platform-neutral and standard way of describing what the service does.

WCF defines five types of contracts.

  • Service Contracts
  • Operation Contracts
  • Data Contract
  • Message contract
  • fault contract.

You can read detailed explanation on each contracts here.

 

4.What is a WCF Binding?  How many different types of bindings available in WCF?

A WCF binding defines how the client needs to communicate with the service.

A WCF service endpoint consists 3 things.
A – Address : Address for the WCF service
B – Binding : How the Client needs to communicate with the service
C – Contract : Defines what the service can do

DIfferent types of bindings available in WCF:

  • basicHttpBinding
  • wsHttpBinding
  • netNamedPipeBinding
  • netTcpBinding
  • netPeerTcpBinding
  • netmsmqBinding

You can read more on WCF binding here.

 

5.What are the possible ways of hosting a WCF service? Explain.

Possible approaches for hosting a service are:

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

You can read more on WAS hosting options here.

You can read more on Self hosting options here.

You can read more on Windows hosting options here.

 

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

 

7.What Message Exchange Patterns (MEPs) supported by WCF? Explain each of them briefly.

Message exchange patterns defines the way client and wcf service exchange messages.

There are mainly 3 type of message exchange patterns.

  • Request-Reply Message Exchange Pattern
  • Oneway Message Exchange Pattern
  • Duplex Message exchange Pattern

You can read detailed article on MEP here.

 

8.What is DataContractSerializer and How its different from XmlSerializer?

Serialization is the process of converting an object instance to a portable and transferable format.

Windows Communication Foundation has DataContractSerializer that is new in .NET 3.0 and uses opt-in approach as compared to XmlSerializer that uses opt-out. Opt-in means specify whatever we want to serialize while Opt-out means you don’t have to specify each and every property to serialize, specify only those you don’t want to serialize.

 

9.Please explain briefly different Instance Modes in WCF?

Instance management  defines the binding of service instance to a request received from a client.in otherwords, Instance context mode identifies how long the service instance remains on server.

There are 3 instancing modes in WCF.

  • Percall
    • A new instance of service object is created for every request regardless if the request is coming from same client or different client
  • Persession
    • A new instance of service object is created for each new client session and maintained for the duration of that session
  • Single
    • A new instance of service object is created and handles all request for the lifetime of the application regardless if the request is coming from same client or different client

10.Please explain different modes of security in WCF?

There are 2 modes of WCF Security.
Transport Security:
Securing transport channel is called transport security.Each protocol has their own way of providing transport security.

TCP provides transport security by implementing Transport Layer Security and HTTP provides transport security by using Secure socket layer.
Message Security:
Securing the message by encapsulating the security credentials with every SOAP message is called message security.

© 2015, admin. All rights reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *