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 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 carries 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.
WCF stands for Windows Communication Foundation. It is a framework that 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".
The main components of WCF are
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.
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
Every service must have an address that determines where the service is located, a contract that defines what the service does, and a binding that tells how to communicate with the service.
WCF defines four types of Contracts
The ways of hosting a WCF service are
Address syntax of WCF transport scheme is
[transport]:// [machine or domain] [: optional port] format
Duplex messaging or call-back is used in WCF to communicate with the client. Over different transport systems Duplex messaging in WCF is done like TCP, Named pipe, and even HTTP. Collectively this is known as duplex contracts in WCF.
To a particular service instance, WCF binds an incoming message request, so the available modes are
In WCF, a service proxy enables applications to interact with the 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 interacts with the service through a proxy, it gives the impression that it’s communicating a local object.
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.
There are two types of Data Contracts
The types of the transaction manager that WCF supports are
|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|
MEP stands for Message Exchange Pattern, three types of message exchanged patterns are allowed.
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 the channel stack. WCF is a unified programming API for any kind of service so we create the service and use the configuration information to set up the communication mechanism like HTTP/TCP/MSMQ etc
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 parties will communicate in terms of transport and encoding and protocols
Contract Specifies the interface between the client and the server. Its a simple interface with some attributes.
Self-hosting the service in his own application domain. This we have already covered in the first section. The service comes into 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.
WCF is flexible because its services can be hosted in different types of applications. The following lists several common scenarios for hosting WCF services:
SOA is Service Oriented Architecture. SOA service is the encapsulation of a high-level business concept. An SOA service is composed of three parts.
ServiceBehaviour attribute is used to specify the InstanceContextMode for the WCF Service class (This can be used to maintain 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 methods 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 the 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 requests. (eg: Global state can be maintained but this will be applicable for all clients)
Fault Contract is used to document the errors that occurred in the service to a client.
Messaging Pattern: Messaging patterns describe how the 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 patterns.
WCF supports the following 3 types of Message Exchange Patterns
.svc file is a text file. This file is similar to our .asmx file in web services.
This file contains the details required for the WCF service to run it successfully.
This file contains the following details :
Example of .svc file
<%@ ServiceHost Language="C#/VB" Debug="true/false" CodeBehind="Service code files path" Service="ServiceName"
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 documents information set consists of many information items? the information set for any wellformed XML document will contain at least a document information item and several others.
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.
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).
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 of about 29,000 to 35,000 dollars a year. The designation will definitely customize 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. Its in high demand and also being used by many companies and individuals.