WCF Interview Questions:
- What is contract in WCF and what all are the different contracts supported by WCF?
- What is the use of ServiceBehavior attribute in WCF?
- What is the difference between DataSerializer and XMLSerializer?
- What is the Message Exhange Pattern and which Messging pattern is supported by WCF?
- What is .svc file in WCF?
- What is Datacontract serializer?
- What all are the transaction managers WCF supports?
- Which binding supports reliable session in WCF?
- 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.
Reference books, you may like:Programming WCF Services: Design and Build Maintainable Service-Oriented Systems
WCF Multi-Layer Services Development with Entity Framework, 4th Edition
Learning WCF: A Hands-on Guide
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.
You can read detailed explanation on Instance Management here.
3. What is the difference between DataSerializer and XMLSerializer?
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.
- Name of the service
- Where the service code resides
<%@ 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.
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.