WCF Interview questions (Part – 3) – Easy WCF
Skip to content

WCF Interview questions (Part – 3)

WCF Interview Questions:

  1. What is contract in WCF and what all are the different contracts supported by WCF?
  2. What is the use of ServiceBehavior attribute in WCF?
  3. What is the difference between DataSerializer and XMLSerializer?
  4. What is the Message Exhange Pattern and which Messging pattern is supported by WCF?
  5. What is .svc file in WCF?
  6. What is Datacontract serializer?
  7. What all are the transaction managers WCF supports?
  8. Which binding supports reliable session in WCF?
  9. What is Service host Factory in WCF?

 

1.What is contract in WCF and what all are the different contracts supported by 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.

2.What is the use of ServiceBehavior attribute in WCF?

ServiceBehavior attribute is used to specify the InstanceContextMode in WCF.

There are 3 InstanceContextMode in WCF.

  • Percall
  • PerSession
  • Single

You can read detailed explanation on Instance Management here.

 

3. What is the difference between DataSerializer and XMLSerializer?

WCF vs ASMX service

DataContract Serializer is new WCF serializer and translates the .net framework objects to XML.

WCF uses data contract serializer and asmx uses XML serializer.

Data Contract serializer is used for better performance.

DataContract serializer shows  which fields or attributes are serialized into XML.

You can read a detailed difference between ASMX and WCF here.

 

4. What is the Message Exhange Pattern and which Messging pattern is supported by WCF?

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.

 

5. What is .svc file in WCF?

.svc file is a text file and it is like asmx file.

This file contains below information.

  • Language
  • Name of the service
  • Where the service code resides

Example:

<%@ ServiceHost Language =”C#/VB” debug=”true/false” CodeBehind=”service code file path” Service=”Service Name” %>

 

6. What is Data Contract Serializer ?

Data Contract in WCF is an agreement between parties (i.e. a service and a client) that describes what type of data will be exchanged between them.

Data Contract allows us to control the name and order of xml element.

You can see a detailed explanation on Data contract and how is it different from Message Contract here.

 

7. What all are the transaction managers WCF supports?

WCF supports 3 types of Transaction managers.

  • Light Weight
  • OLE transaction
  • WS Atomic Transactions

you can read a detailed explanation on WCF Transactions here.

 

8.Which binding supports reliable session in WCF?

Following bindings support reliable sessions in WCF.

  • wsHttpBinding
  • wsDualHttpBinding
  • wsFederationHttpBinding
  • netTCPBinding

 

9.What is Service host Factory in WCF?

Service host Factory is a mechanism by which we can create the instance of service host dynamically as the request comes in.

This is helpful to implement event handler to open and close the service.

WCF provides ServiceFactory class to handle this.

 

 

© 2015, admin. All rights reserved.

Leave a Reply

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