WCF stands for window communication foundation. This article will explore some of the questions you should expect if you have an upcoming WCF Interview. Take a look at the following:
1. Define WCF
WCF stands for Windows Communication Foundation, a distributed technology that offers a single and fully integrated service model helping developers create distributed applications for Windows. It was introduced to improve inter-application communication consistency, challenged by distributed technologies such as Enterprises and XML Web services. It also offers improved security and reliability of these distributed applications while enhancing interoperability with other distributed technologies. It is also worth noting that this technology also utilizes Simple Object Access Protocol messages for information exchange.
2. Can You Mention the Different Layers of WCF
Given that this technology supports both service and clients, it has a unique architecture, which is mainly service-oriented. These include four layers: contracts, service run-time, activation and hosting, and messaging. The contracts define the various functionalities that the service exposes to the client while the service run-time deals with the service’s time behaviours. On the other hand, messaging deals with the channels that process and exchange information, while activation and hosting define how the WCF service is hosted.
3. Can You Tell Us More about SOA
SOA is the abbreviation for service-oriented architecture found in WCF. It is a unique design pattern directing that every system component must be a service. Services in WCF means units or programs serving as business processes. In SOA, the system must also be made up of several loosely coupled services that must be independent. This level of independence means that a different system is not affected when any one of them is changed.
4. Define WCF ABC
ABC in WCF stands for address, binding and contract. The address answers the ‘where’ or the hosted service’s location. This address is specified as a URI, where the first parts tell the transport protocol while the others point at the host machine address and service path. Binding answers the ‘how’ or the communication mechanism between the service and the client. It consists of several binding elements. Lastly, the contract answers the ‘what’, thus specifying the components of the service. These contracts include operation, service, message, data, and fault contracts. It is worth noting that all these contracts define behaviours.
5. Explain the Different Service-Oriented Principles
Service-Oriented architecture has four service-oriented principles. First, boundaries are explicit, meaning that a service can be deployed from any location and can be easily accessed by other services; development language and environment notwithstanding. The services are also autonomous, meaning that they must be versioned and managed differently to avoid affecting other services. The third principle states that service compatibility is based on policy. Therefore, each service must have its compatibility level and have a way of interacting with others. Lastly, services do not share schema and contracts but class.
6. Define SOAP in WCF
SOAP stands for Simple Object Access Protocol. It is used to exchange data over HTTP. Web services normally use this protocol for data exchange services in XML based format. THEREFORE, a SOAP message structure is unique to other data exchange structures since it has an optional header and mandatory body requirement. The header, the first child element, normally captures all the application-specific information such as authentication and authorization. On the other hand, the body element has the SOAP message.
7. Explain the WS-* Protocol in WCF
WCF has SOAP protocols used to exchange information between different web services. However, the WS-* protocols are quite different as they have semantics that can be reused across applications. These are a set of protocols that allow the implementation of additional service needs and behaviours. They tell how one can exchange information reliably and securely through the headers in a SOAP message. WCF implements protocols through WsHttpBinding, contributing to a range of needed behaviours such as addressing, discovery, reliability and message calls.
8. Compare WCF to ASP.NET Web Service
There are several differences between WCF and ASP.NET Web Service. First, WCF has ServiceContract and Operation contract attributes that define WCF services, whereas the latter uses Web service and WebMethod for the same purpose. WCF supports several protocols such as TCP, HTTP, HTTPS and MSMQ, while ASP.NET only supports HTTP and HTTPS protocols. The former is hosted in IIIS, WAS, windows service and self-hosting, while ASP.NET is hosted only in IIS. Additionally, WCF is relatively faster than ASP.NET since the latter depends on web services. Lastly, HashTable can be serialized in WCF but not in ASP.NET. The latter can only serialize collections implementing Icollection and IEnumerable.
9. What are the Different Endpoints in WCF?
There are two endpoints in WCF, namely default and standard endpoints. The default endpoints are only offered to a given service if the host has at least one base address but no endpoints. For the default endpoints, basic binding for the HTTP address is used. WCF also has standard endpoints, a set of pre-defined endpoints facilitating metadata exchange, web and discovery. You only need a config file and some programming to configure these endpoints. Common standard endpoints are mexEndpoint, webHttpEndpoint, webScriptEndpoint and discoveryEndpoint.
Click Here to download 3000+ Project Management Documents: Complete Library of Project Management Templates, Processes, Plans, Checklists, Forms, Tools, Presentation Slides and Infographics. Suitable For All Industries.
10. Define Instance Management in WCF
WCF often creates an instance of the service calls to manage a session. The main purpose of the created instance is to respond and manage the incoming service requests. On the other hand, the session addresses the service instances helping the server use the developed models in an optimized manner. It is also worth noting that InstanceContext manages service class instances on the server side. There are different instance management ways such as single, per session and per call. All these are unique and serve different occasions.
11. You Must Have Heard of Concurrency Management in WCF. Can You Explain What it is?
Concurrency Management is closely linked to instance management. However, they serve different purposes and are therefore totally different. Whereas instance management specifies the creation of service instances, Concurrency management defines the number of concurrent requests to be handled by a service instance. Concurrency can also make a service instance thread-safe, coming in handy for per-session service instances, which are not normally thread-safe since a single service instance serves several client requests. However, one won’t need concurrency management in per call instances since they are thread-safe by default.
12. Define WCF Data Service
The WCF Data Service utilizes OData, or the open data protocol, to query and manipulate data. These services are normally founded in WCF REST Services, responsible for CRUD operations on a given database relying on the HTTP protocol. It also supports a range of database operations via URI. While mentioning the WCF Data Service, it is worth noting that the data protocol, which is closely linked to it, exposes data from the required databases, file systems, services and websites through the XML and JSON formats.
13. What is Impersonation? What Are Its Limitations?
Impersonation is a common process in WCF. It serves as a means of confirming a caller identity, thus allowing the client to access any required resources in the service database, which may either be local files or different database tables. All these must be found on the same machine hosting the service. However, impersonation is not usually enabled all the time. It is by default disabled due to security reasons. Instead, resources and any other necessary information is often accessed through the process identity offered by the WCF service.
14. Mention the Advantages of WCF
WCF has a number of advantages. First, it has a service-oriented architecture, which explains why it is normally faster than other technologies such as ASP.NET. Secondly, it is both location and language-independent, allowing easy access and manipulation. WCF is also versatile since it supports several simultaneous operations. It can further maintain state and concurrency, giving clients and users an easy time. These also make the system more reliable. Other advantages include the ability to preserve transactions similarly to COM+, the ability to maintain state and the fact that it can be hosted on a number of platforms such as windows services WAS, IIS or even self-hosting.
15. Why Should One Stream with WCF?
WCF has a streaming transfer mode that comes in handy whenever there is a large amount of data to transfer. It does not present the challenge of buffering and processing of messages that other alternative technologies experience. After receiving a message in WCF, it is only delivered after the whole message has been received. It, therefore, buffers at the receiving side and only gets delivered to the receiving end after full reception. However, the only downside is that this process makes the receiver’s end unresponsive.
16. Mention the Types of Data Contracts in WCF
In WCF, a data contract refers to a formal agreement between the client and service describing the data that should be exchanged. Therefore, data contracts are either explicit or implicit. WCF uses a data contract serializer that acts in default to serialize and deserialize data. There are only two types of data contracts in existence, namely data member and data contract. In the data member, quality is normally used to define the properties of the data, while in the data contract, the class is determined by the attributes.
17. Mention the Transaction Managers Supported by WCF
Transactions in WCF refer to sets of operations that follow a number of properties known as ACID. To specify, WCF supports only three transaction managers: Light Weight, OLE Transaction and WS-Atomic Transaction. To set Transactions in WCF, you must first have an introduction and a goal before creating two WCF services and attributing the interface methods with TranscarionFlow. One should then enable Transactions flow using the WCF Service ConfigFile and call the two service in one Transaction. This shouldn’t be hard if you are used to the WCF platform.
18. Explain the Different Contracts in WCF
A contract in WCF refers to what the service exposes. It combines different related operations into single units. There are four different types of contracts, namely operation, message, fault and data contracts. The operation contract has the parameters as return types of various operations. It is normally signed when creating an interface defining the service contract while the message contract explains the message format. The fault contract can tell the errors to be returned to a caller. Lastly, the data contract describes the data types that a service uses via metadata, permitting interoperation with a given service.
19. Mention Some of the Components Used in WCF
The three main components used in WCF are the service class, endpoint and the hosting environment. The endpoint makes it possible to communicate with the world as they handle all the communications in WCF. The hosting environment is where the service is located/hosted. The host, therefore, controls the service’s lifetime. Lastly, the service class, located in the run-time service layer, details the run-time service behaviours that only occur during a given service operation. Therefore, it controls the messages to be processed, which can vary depending on service demands.
20. Explain the Different Instance Modes on WCF
The three instance modes on WCF are per call, per session and singleton. The ‘Per Session’s mode develops a logical session between service and client to be maintained in the session’s lifetime. The session is normally created after a client request and dedicated to the instance. On the other hand, the per-call instance mode is an instance of service designed for every method only to be deleted once a client gets the response. Lastly, all the clients are connected to a single instance in the singleton instance mode. An instance is then created during hosting only to be eliminated after shut down.
21. What Does it Take to Host a WCF Service?
There are several requirements for hosting a WCF service. To host a WCF service, one must have a managed process, ServiceHost instance, and a configured Endpoint. There are also several hosting service approaches, including self-hosting/ hosting in managed applications, window service, console application, web server hosting, windows process activation service or WAS, which supports TCP, NamedPipes, HTTP and MSMQ and windows application. These several hosting possibilities explain why WCF is popular.
22. Tell Us about the Different Isolation Levels in WCF
There are five isolation levels in WCF. The Read Uncommitted level, popularly known as the dirty isolation level, ensures that any corrupt data is not read. It is the lowest isolation level. The Read Committed data level ensures that any non-committed data that has been changed by any application is not read. We also have the Repeatable Read level, which inhibits the use of non-repeatable and dirty read data. It locks any data fetched by a given query and stops further updates. The remaining isolation levels are the serializable and snapshot isolation levels. The former inhibits modification or addition of new data until a transaction is complete, while the snapshot level brings to attention any error associated with data modification.
23. Explain the Different Modes of Communication in WCF
WCF has three communication modes. The callback model is used to call a client. The service, therefore, acts as a client while the client acts as a service. The one-way operation mode sends a request to the server whether it succeeds or fails in service execution. The request-reply mode directs that a client has to wait for a response from a given service after making a request. It executes the rest of the statement only after getting the response.
24. Define Duplex Contracts in WCF
In WCF, duplex contracts collectively refer to duplex messaging and its pipeline. Also known as a callback, duplex messaging is used to communicate with different clients. Therefore, a duplex service contract refers to a message exchange pattern that allows the independent exchange of messages between other endpoints, thus offering event-like behaviour. In this type of communication, a client connects to a given service with a channel of sending back messages to the client. This only works within a given session.
25. Mention What Binding Means in WCF and List a Few Types of Binding in WCF
Binding refers to the communication mechanism of an endpoint. WCF has binding elements containing different details, such as security mechanisms. Common types of binding in WCF are basic, TCP, IPC, peer networking and web services binding. As the name suggests, basic binding uses text/XML as default message encoding and HTTP as its transport mechanism. On the other hand, NET TCP binding can develop a run-time communication stack by default. It uses TCP to deliver messages and also has binary message encoding. Lastly, IPC binding uses named pipes to facilitate communication between a range of services.
We have explored some of the commonly asked questions in WCF interviews, which should help you prepare well for your upcoming interview. Make sure that you thoroughly go through them and give the interviewers an excellent first impression to ace your interview. We wish you all the best in your upcoming interview.