WCF Interview Questions
When you are well prepared it is not a tough task to crack the interview. When you are acting as a specialist in WCF then you must have enough information and knowledge to make the interview communication interesting. The following information will help you to get the answers to the WCF Interview Questions. Do not worry if you are facing the interview for the first time. The basic information about WCF will help you a lot to answer during the interview.
The term WCF stands for Windows Communication Framework. It is designed to make the communication within the device easier and clear. It can support operations like MS messaging, Queuing, services, tempting etc. You can also communicate through this framework with other non-Microsoft technologies. This communication framework helps to pass messages between software. Basically, this framework takes the software as a service provider and carry the services from one place to another with some codes with are the alphabets of this communication framework. Basically, this framework has been generated to use in service-oriented applications or software. The framework can better instruct and also carry exact information to the given destination.
Best WCF Interview Questions of 2020
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. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. 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 to enable/disable logging using configuration.
Its code name is "Indigo".
2. Mention what are the main components of WCF?
Main components of WCF are
- Service: The working logic
- Host: The path where the data is saved. E.g., .exe, process, windows service
- Endpoints: The way the service is exposed to the outside world
3. Explain how does WCF works?
WCF follows the “Software as a Service” model, where all units of functionality are defined as services. 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.
4. Explain what is the difference between ASMX web services and WCF?
The difference between WCF and ASMX or ASP.net web service is that ASMX is designed to send and receive messages using SOAP over HTTP only. While the WCF can exchange messages using any format over any transport protocol
5. Mention what is the endpoint in WCF and what are the three major points in WCF?
Every service must have an address that determines where the service is located, contract that defines what the service does and binding that tells how to communicate with the service.
- Address: It specifies the location of the service which will be like http://Myserver/Myservice. To communicate with our service client it will use this location
- Contract: It specifies the interface between the server and client. It’s a simple interface with some attribute
- Binding: It decides how two parties will communicate with each other in terms of transport and encoding and protocols
6. Explain how many types of contract does WCF defines?
WCF defines four types of Contracts
- Service Contracts
- Data Contracts
- Fault Contracts
- Message Contracts
7. What are the transport schemas does WCF supports?
- Peer network
- IPC ( Inter Process Communication)
8. Mention what are the ways of hosting a WCF service?
The ways of hosting a WCF service are
- WAS (Windows Activation Service)
9. Mention the address syntax and the different formats of WCF transport scheme?
Address syntax of WCF transport scheme is
[transport]:// [machine or domain] [: optional port] format
10. In WCF what are duplex contracts?
Duplex messaging or call-back is used in WCF 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.
11. Mention what are the different instance modes in WCF?
To a particular service instance WCF binds an incoming message request, so the available modes are
- Per Call: This instance is created for each call, efficient in terms of memory but need to maintain session
- Per Session: For a complete session of a user instance are created
- Single: One instance is created which is shared among all the users and shared among all. In terms of memory it is least efficient.
12. Explain what is a Service Proxy in windows Communication Foundation?
In WCF, a service proxy enables applications to interact with WCF service by sending and receiving messages. It’s a class that covers service details like service path, service implementation technology, platform and communication protocol and so on. So, when the application interact the service through proxy, it gives the impression that it’s communicating a local object.
13. Explain what is SOA?
SOA (Service Oriented Architectural) is a collection of services that determines how two computing entities will communicate with each other to achieve certain business functionality and also how one entity can work on behalf of another entity.
14. What are the types of Data Contracts in WCF?
There are two types of Data Contracts
- Data Contract: Attribute used to define the class
- Data Member: Attribute used to define the properties
16. What are the three types of transaction manager WCF supports?
The types of the transaction manager that WCF supports are
- Light Weight
- WS- Atomic Transaction
- OLE Transaction
17. List out the difference between XMLSerializer and the DataContractSerializer?
|For WCF, DataContractSerializer is the default serializer
||XMLSerializer is not a default serializer
|Compare to XMLSerializer it is faster
||XMLSerializer is slower
|It is used for simple schemes
||It is used for complex schemes
18. Explain what are the MEPs available in WCF?
MEP stand for Message Exchange Pattern, three types of message exchanged patterns are allowed.
- Data Gram
- Request and Response
19. What Is The Difference Wcf And Web Services?
Web services can only be invoked by HTTP (traditional webservice with .asmx). While WCF Service or a WCF component can be invoked by any protocol (like http, tcp etc.) and any transport type.
Second web services are not flexible. However, WCF Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends.
We develop WCF as contracts, interface, operations, and data contracts. As the developer we are more focused on the business logic services and need not worry about channel stack. WCF is a unified programming API for any kind of services so we create the service and use configuration information to set up the communication mechanism like HTTP/TCP/MSMQ etc
20. What Is Three Major Points In Wcf?
We Should remember ABC.
Address Specifies the location of the service which will be like http://Myserver/MyService.Clients will use this location to communicate with our service.
Binding Specifies how the two paries will communicate in term of transport and encoding and protocols
Contract Specifies the interface between client and the server.It's a simple interface with some attribute.
21. What Are The Various Ways Of Hosting A Wcf Service?
Self hosting the service in his own application domain. This we have already covered in the first section. The service comes in to existence when you create the object of ServiceHost class and the service closes when you call the Close of the ServiceHost class.
Host in application domain or process provided by IIS Server.
Host in Application domain and process provided by WAS (Windows Activation Service) Server.
22. Difference Between Wcf And Web Services?
- It Can be accessed only over HTTP
- It works in stateless environment
WCF is flexible because its services can be hosted in different types of applications. The following lists several common scenarios for hosting WCF services:
- Managed Windows Service
23. What Is A Soa Service?
SOA is Service Oriented Architecture. SOA service is the encapsulation of a high level business concept. A SOA service is composed of three parts.
- A service class implementing the service to be provided.
- An environment to host the service.
- One or more endpoints to which clients will connect.
24. What Is The Use Of Servicebehavior Attribute In Wcf ?
ServiceBehaviour attribute is used to specify the InstanceContextMode for the WCF Service class (This can be used to maintained a state of the service or a client too)
There are three instance Context Mode in the WFC
PerSession : This is used to create a new instance for a service and the same instance is used for all method for a particular client. (eg: State can be maintained per session by declaring a variable)
PerCall : This is used to create a new instance for every call from the client whether same client or different. (eg: No state can be maintained as every time a new instance of the service is created)
Single : This is used to create only one instance of the service and the same instance is used for all the client request. (eg: Global state can be maintained but this will be applicable for all clients)
25. In Wcf, Which Contract Is Used To Document The Errors Occurred In The Service To Client?
Fault Contract is used to document the errors occurred in the service to client.
26. What Is The Messaging Pattern? Which Messaging Pattern Wcf Supports?
Messaging Pattern : Messaging patterns describes how client and server should exchange the message. There is a protocol between client and server for sending and receiving the message. These are also called Message Exchange Pattern.
WCF supports following 3 types of Message Exchange Patterns
- request reply- (default message exchange pattern)
- OneWay (Simplex / datagram)
27. What Is .svc File In Wcf?
.svc file is a text file. This file is similar to our .asmx file in web services.
This file contains the details required for WCF service to run it successfully.
This file contains following details :
- Language (C# / VB)
- Name of the service
- Where the service code resides
Example of .svc file
<%@ ServiceHost Language="C#/VB" Debug="true/false" CodeBehind="Service code files path" Service="ServiceName"
28. What Is Xml Infoset?
The XML Information Set defines a data model for XML. It is an abstract set of concepts such as attributes and entities that can be used to describe a valid XML document. According to the specification, "An XML document's information set consists of a number of information items; the information set for any wellformed XML document will contain at least a document information item and several others.
29. What Is Datacontractserializer In Wcf?
DataContractSerializer is new WCF serializer.
This is serialization engine in WCF. DataContractSerializer translate the .NET framework objects into XML and viceversa.
By default WCF uses DataContractSeriazer.
30. What is the advantage of an array over individual variables?
When storing multiple related data, it is a good idea to use arrays. This is because arrays are named using only 1 word followed by an element number. For example: to store the 10 test results of 1 student, one can use 10 different variable names (grade1, grade2, grade3… grade10). With arrays, only 1 name is used, the rest are accessible through the index name (grade, grade, grade… grade).
Career scopes and salary scale
Since the field is extremely interesting the career opportunities are also interesting. You can get places in the framework industry; you can get placed in many IT and software companies. It also comes with a handsome salary package about 29,000 to 35,000 dollars a year. The designation will definitely customise the salary scale. The basic salary package starts with 100,000 to 115,000 dollars a year but here the salary scale doesn’t end.
The world is running on software and applications. This amazing communication framework has helped the software developers to generate the intercommunication system between the software and the user. WCF is one of the most required elements of developing service software. It's in high demand and also being used by many companies and individuals.