WCF Interview Questions and Answers

Thumb

Author

BIQ

Questions

16

Last updated

Feb 6, 2023

WCF is an abbreviated form of Windows Communication Foundation, which is a unified communication framework developed for distributed applications. In other words, it is a unified API for services and clients for the purpose of sending information between each other. The main characteristics of WCF are SOA, extensibility, and interoperability. This is the prime and most important information which is often asked during WCF Interview Questions. Given below are the commonly asked interview questions that will help you to crack WCF interviews. SOA (Service-Oriented Architecture) is an approach to protocol-independent, loosely coupled and standard-based distributed computing where software resources that are available over the network are considered as a service. Likewise, interoperability is also a prime feature of WCF, as it implements a number of WS-*standards. Even, WCF client/server platform configures itself to interoperate with REST, ATOM-feeds, Plain XML or JSON messages. Therefore, WCF provides a secure, reliable and transacted messaging platform along with interoperability.

Most Frequently Asked WCF Interview Questions

Here in this article, we will be listing frequently asked WCF Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q1. What is WCF and why it is used?
Answer

WCF is an abbreviated form of Windows Communication Foundation. In general, it is widely used to create and generate the interoperable, scalable and distributed application. .NET 3.0 is a WCF applications framework which is used for the creation of service-oriented and aligned applications. With the help of this framework, users can send asynchronous data from one part to another.

Therefore, WCF applications can be used in a distributed system that can be run on multiple systems without any sort of compatibility barriers.

Q2. What is difference between Web API and WCF service?
Answer
Web API WCF service
Web application programming interface which is primarily used for the creation of full-blown REST a service which implies that WEB API does not need any data configuration and contracts to the level of WCF. WCF was created for the development of SOAP-based services. It uses standard XML and schema over HTTL which leads to the degradation in the performance of the application.
WEB API support Any media content format It uses Text format that includes XML
It uses URL patterns, HTTP methods as a service interface WCF uses service contract as a service interface
The caching mechanism of WEB API is built-in HTTP application control The caching mechanism of WCF service is handled by the application
Q3. What is message contract in WCF?
Answer

Massage contract in WCF is used to define the structure of data. It is important to define the structure of data before the application sends the packet from source to destination. In addition to this, the message contract is also used to control and maintain the structure of information (Message body) and serialization of process.

Q4. What is address binding in WCF?
Answer

In general, WCF is an advanced level programming platform which is used for building, running and deploying application over distributed network services. Address finding in WCF is a technique which is used for binding the location address and transport address which is used for the establishment of communication with two peers.

Q5. What is endpoint in WCF service? Also explain its types.
Answer

Endpoints in WCF service is used for the purpose of establishing communication between endpoints of the services. With the help of endpoints, users can access the offered functionalities of the WCF services.

Four properties of endpoints-
  • An address which is used to find the endpoint.
  • The binding which specifies how the client can establish communication with the endpoint
  • A binding that specifies how a client can communicate with the endpoint.
  • A contract is used for the identification of operational variable
  • A set of behaviors that specify and states implementation details of the endpoint.
Type of WCF Endpoints
  • Impersonate
  • ServiceAccount
  • OAuth
  • Static
  • Single Single-on
Q6. Why Datacontract is used in WCF?
Answer

A data contract is a formal agreement which is held between the client and service provider in which the data exchange method is explicitly defined. Additionally, with the help of data contract, the data is serialized and can be exchanged among two different entities.

Q7. What is hosting in WCF?
Answer

After creating a WCF service, it is important to host the designed service so that client applications can use it. Additionally, WCF services can be hosted with the help of four ways namely- ISS (Internet Information Service) hosting, Self-hosting, WAS (Windows Activation Service) hosting, Windows Service Hosting.

Q8. What are the ways for exception handling in WCF?
Answer

In general exception handling is one of the features of object programming language and it is an error that accurate which occurs runtime. Exception handling is a technique which is used to handle runtime errors. In order to handle expectations try, catch and finally block are used. Id the expiration handling technique is unable to handle the runtime error then the execution of the application automatically terminated.

There are three ways of handling exception in WCF

  • Faultexception
  • IErrorHandler
  • returnUnknownExceptionAsFaults
Q9. What is known type attribute in WCF?
Answer

KnownTypeAttribute is an attribute which allows specifying the types that should be included during the process of deserialization. The users are using KnownTypeAttribute only when they want to accept the service and return an inherited type.

Q10. What is HTTP binding in WCF?
Answer

In practice, HTTP binding is suitable for communicating securely with ASP.NET Web service (ASMX) based services. In addition to this, WCF services use HTTP binding service in order to transport text/XML ass a default message.

In order to create HTTP binding in WCF following steps need to be performed

  • Create WCF HttpBinding project
  • Open Visual Studio
  • Create a New Project from the start page
  • Go to File menu, select New and then click on the project
  • A dialog box will pop up over the display screen
  • With the help of installed templates select C#
  • Inside C# select WCF and then select WCF service application
Q11. Can we have method overloading in WCF?
Answer

Yes, we have method overloading in WCF. In the general method, overloading is one of the optimal features that allow the users to create multiple methods with the same name but each method performs different functionality from each there in the context of input and output. In other words, method overloading methods name will be the same but the parameters differ from each other. Method overloading is used during compile time polymorphism.

Q12. What is Duplex in WCF?
Answer

Duplex in WCF allows clients and server to establish a communication pathway with each independently in which any of the entity can initiate a call to others. In order to establish communication between the source and destination duplex mode of communication would be used. If one entity is sending a message at the time another entity will receive the message. Moreover, in the duplex mode of communication, both source and destination will participate in the communication activity.

Q13. How many types of binding are there in WCF?
Answer

There are different type of binding in WCF namely-

  • BasicHttpBinding
  • WSHttpBinding
  • WSDualHttpBinding
  • WSFederationHttpBinding
  • NetTcpBinding
  • NetNamedPipeBinding
  • NetMsmqBinding
  • NetPeerTcpBinding
Q14. What do you mean by throttling Behaviour in WCF?
Answer

Throttling is a word which is derived from throughput keyword, it means work performed within the specific intervals of time. The throttling behavior in WCF is defined as a number of session user creates within a stipulated period of time.

Q15. How many requests can a WCF service handle?
Answer

WCF service handles new about 40 requests and WCF handles each request with the help of call which implies that one instance of WCF service will be created for each request.

Q16. What are Volatile and Dead letter queues?
Answer

Volatile letter queues- This is a queue which is used when you send information or message and want that message to be delivered on the proper time.

Dead letter queues- This queue is required so that client and server are not needed to run at the same time when the message is delivered.