HI WELCOME TO SIRIS

WCF Interview Questions

Leave a Comment

There is given frequently asked WCF interview questions and answers that has been asked in many companies. Let's see the list of top WCF interview questions.


1) What is WCF?

WCF stands for Windows Communication Foundation. It is a framework which is used for building, configuring and deploying interoperable distributed services. It provides a facility to write more secure flexible services without any code change. It also provides built-in support for logging. It facilitates you for enable/disable logging using configuration.
Its code name is "Indigo".

2) What are the WCF service endpoints?

WCF service endpoint has three basic elements: address, binding and contract.
  • Address: It defines the address of the URL that identifies the location of the service.
  • Binding: It defines how the service can be accessed.
  • Contract: It defines what is exposed by the service.

3) What are the essential components used in WCF?

A list of essential components used in WCF:
  • Service class
  • End point
  • Hosting Environment

4) What is the "Address" property of endpoint in WCF?

The "Address" property is the part of endpoint defined in service level. This property is used to specify the location where the service is located.

5) What is the "Binding" property of endpoint in WCF?

The "Binding" property is the part of endpoint defined in service level. This property is used to specify the type protocols, encoding's and transport.
These all factors are decided by both the communicating parties.

6) What is the "Contract" property of endpoint in WCF?

The "Contract" property is just an interface between client and server where client and server communicate each other. Contracts are used to specify operations available.

7) What is service?

A service is a set of functionality exposed to the world. Service orientation (SO) is an abstract set of principles and best practices for building service-oriented applications.

8) What is service proxy in WCF?

WCF Proxies are used to communicate between client and server. The communication takes place by exchanging the messages in the form of requests and responses. It will have the details like Service Path, Protocol details and so on.

9) What is "Service Contracts" in WCF?

The Service Contracts attribute is used at the service level for WCF service. It provides the list of operations that can be performed from that service.
Service Contracts can be defined like:
[ServiceContract]

10) What are different instance modes in WCF?

A list of instance modes in WCF:
  • Per Call
  • Singleton
  • Per Session

11) What is "Per Call" instance mode in WCF?

When a request has made to service, it creates a new instance of service for each method call and this will be disposed once the response goes to client. This whole process is known as per call instance mode.

12) What is "Per Session" instance mode in WCF?

Per session instance mode creates a logical session between service and client and it will be maintained till the end of the session. When client requests from service the session will be created and it is dedicated to instance for that client and it will going to end when client session ends.

13) What is "Singleton" instance mode in WCF?

In "Singleton" mode all the clients are connected to the single instance of the service and when service configured for "Singleton" mode, instance will be created when service is hosted and it will be disposed once its shuts down.

14) What do you mean by client?

The client of a service is the program unit consuming its functionality. A client can be anything like Console application, Windows form, WPF or Silverlight class or ASP.Net page etc.

15) How does WCF works?

WCF follows the model "Software as a Service". In this model all units of functionality are defined as services and for communication, each point is a portal or connection either with the client or other services. It is a program that exposes a collection of endpoints.

16) What is the difference between ASMX web services and WCF?

The main difference between WCF and ASMX web service is that ASMX is designed to send and receive messages using SOAP over HTTP only while WCF facilitates you to send and receive messages using any format over any transport protocol.
ASMX web service is also known as ASP.Net web service.

17) How many types of contract WCF define?

There are four types of contracts that WCF define:
  • Service Contracts
  • Data Contracts
  • Fault Contracts
  • Message Contracts

18) What are the requirements for hosting a WCF service?

You need at least a managed process, a ServiceHost instance and an Endpoint configured for hosting a WCF service.
Following are the possible approaches for hosting a service:
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.

19) Which are the different isolation levels in WCF?

Following is a list of different isolation levels in WCF:
  • Read Committed
  • Read Uncommitted
  • Serializable
  • Repeatable Read

20) Give the address format of all the bindings in WCF.

A list of address formats and their respective bindings:
  • TCF Address Format - net.tcp://local host:portnumber
  • HTTP Address Format - http://local host:portnumber
  • MSMQ Address Format - net.msmq://local host:portnumber

21) Explain the WCF RIA?

WCF RIA is the framework for developing n-tier application for RIA (Rich Internet App). It is used in Rich Internet Apps like Silverlight, AJAX etc. WCF RIA is used to solve the major problems like Tight Coupling.

22) How would you generate proxy for WCF?

You can generate proxy by using the following steps:
  • Using Visual Studio
  • Using SvcUtil

23) What is binding?

Binding is used to define how an endpoint communicates to the world. It defines the transport such as HTTP or TCP. It can contain binding elements that specify details like the security mechanisms used to secure message patterns used by an end point.

24) What are the different modes of communication in WCF?

There are three modes of communication in WCF:
  • One-Way
  • Request-Reply
  • Callback

25) What is request-reply mode in WCF?

When a client made a request to a service, it will wait until it gets the response back.
  • If the response is not received till the given time, it will show an error.
  • If client gets the response then next instructions will be executed.

26) How many types of binding are there in WCF?

WCF supports nine types of bindings:
  • Basic binding
  • TCP binding
  • Peer network binding
  • IPC binding
  • Web Services binding
  • Federated Web Service binding
  • Duplex WS binding
  • MSMQ binding
  • MSMQ integration binding

27) What are the transport schemas supported by WCF?

WCF supports the following transport schemas:
  • HTTP
  • TCP
  • PEER network
  • IPC (Inter Process Communication)
  • MSMQ

28) What are the ways of hosting a WCF service?

The ways of hosting a WCF service are:
  • IIS
  • Self-Hosting
  • WAS(Window Activation Service)

29) What are the duplex contracts in WCF?

In WCF, Duplex messaging or call-back is used to communicate with the client. Over different transport system Duplex messaging in WCF is done like TCP, Named pipe and even HTTP. Collectively this is known as duplex contracts in WCF.

30) What is the usage of DataContracts in WCF?

In WCF we can communicate with server from our client through message. So messages will be going to and fro between server and client. For security purpose we are serializing the messages sent across the wire.
"[DataContact]" attribute given at class level to serialize the class by using "[Datamember]" attribute over properties.

31) What is DataContractSerializer?

DataContractSerializer is introduced in .NET 3.0 and WCF uses DataContractSerializer as default one. But now this serializer can be used for other serialization purposes also. For serialization "WriteObject()" method is used.
For example:
DataContractSerializer dataContractSerializer = new
DataContractSerializer(typeof(MyTestClassType));

32) How would you enable the metadata information of the service?

Following are two ways to enable the metadata for WCF:
  • For Default Endpoint: <serviceMetadata> tag is used in web.config file without specifying the endpoint.
  • For Custom Endpoint: <serviceMetadata> tag is used in web.config file with specifying the defined endpoint.

33) Which bindings are used for metadata configuration in WCF?

A list of bindings that are used for metadata:
  • mexHttpBinding
  • mexNamedPipeBinding
  • mexHttpsBinding
  • mexTcpBinding

34) How can you test a WCF application without creating client application?

There is a tool called - "wcftestclient.exe" used for testing the WCF service without creating a client application. This tool can be opened from visual studio command prompt.

35) What is transport and message reliability?

Transport reliability: It offers point-to-point guaranteed delivery at the network packet level, as well as guarantees the order of the packets.
Message reliability: It deals with reliability with message level independent of how many packets are required to deliver the message.

36) What is Transport Reliability in WCF?

"Transport Reliability" specifies the guarantee of delivering packets over network as protocol TCP does. It also maintains the order of the packets as well as delivering of packets.

37) What is SOA?

SOA stands for Service Oriented Architecture. It is a collection of services that determines how the communication is possible between two computing entities to achieve certain business functionality and also how one entity can work on the behalf of other entity.

38) What is the usage of "receiveTimeout" property in WCF?

The recieveTimeout property is used to get/set the time interval to makes a connection active.

39) How can you generate proxies using Svcutil in WCF?

SvcUtil is a command line utility. YOu should write the following command to generate proxy:
  1. svcutil /t:code http://<mycreatedserviceurl>/out:<file_name>.cs /config:<file_name>.config   

40) Which styles of models are supported in WCF?

WCF service supports 2 styles of models:
  • RPC style: In RPC style we can use the serialize types and it provides the feature that are available for local calls.
  • Message style: In message style WCF allows the message header to be customized and it also allows us to define the security for body and header messages.

41) What is the one way mode in WCF? Explain.

In WCF one way mode, client sends a request to the server but does not wait till the response comes. It does not care if the request is failed or succeeded. Client will not be blocked in this case till it receives the response.

42) What is Callback mode in WCF? Explain.

Ans: The WCF callback mode is a special type of mode where WCF on call back calls the method of client and in this scenario WCF service acts like a client and client acts like a service.
This mode is not supported by "HTTPBinding" so "WSDualHttpBinding" is used in this mode.

43) What are the different types of transaction managers supported by WCF?

These are three types of transaction managers supported by WCF:
  • Light Weight
  • WS-Atomic Transaction
  • OLE Transaction

44) What are the MEP's in WCF?

MEP stands for Message Exchange Pattern. There are three types of Message Exchange Patterns are allowed:
  • Data Gram
  • Request and Response
  • Duplex

45) What is the address format in WCF?

Syntax of address format in WCF:
  1. [transport]://[machine or domain][optional port number]  

46) What is Throttling in WCF?

In WCF, "Throttling" is used to limit the sessions or instances to be created at application level. It is used to boost the performance.

47) What is the usage of "maxConcurrentCalls" in Throttling?

The "maxConcurrentCalls" attribute in throttling is used to limit the total number of calls which are going to the service instances. Its default value is 16.

48) What is "Know Types" in WCF?

The KnowType is an attribute which is used to the parent class because if you define the complex class as the property of class then it would be very difficult for the compiler during de-serialization process.

49) Give an example of KnowType.

See this example:
  1. [KnownType(typeof(TestClassCar))]    
  2. [KnownType(typeof(TestClassTruck))]    
  3. [DataContract]    
  4. public class TestClassVehicle     
  5. {    
  6. }    
  7. [DataContract]    
  8. public class TestClassCar : TestClassVehicle    
  9. {    
  10. }    
  11. [DataContract]    
  12. public class TestClassTruck : TestClassVehicle    
  13. {    
  14. }    

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.