WCF Interview Questions and Answers

Author: Venkatesan Murugan

Q1.What is WCF? Briefly explain.

Windows Communication Foundation is a Software development kit (SDK) to develop and deploy services in Windows. WCF provides a runtime environment for services. It enables Common Language Runtime (CLR) kinds of services to be exposed, while consuming other services as CLR types. WCF is a part of the.NET 3.0 framework and it requires.NET 2.0, and it can run only on systems that support it.

Q2.What are the main components of WCF?

We need to define three main components in WCF:-

  • Service class.
  • Hosting environment
  • End point

Q3.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.

Q4.What are the protocols used in Message Layer in WCF?

There are some functionality of protocols which are used in messaging layer in WCF.

Ws-Security Channel:- It enables.to secure the message by implementing the ws-security specification in the messaging layer of a service.

Ws-Reliable Messaging Channel:- This protocols gives guarantee to deliver the message over channels.

Encodes:- It provides the number of encodes for message.

HTTP Channel:- It specifies that HTTP is used for delivering a message.

TCP Channel:- It specifies that TCP is used for delivering the message.

Transaction flow Channel:- It define the pattern in which a message is transacted.

Named Pipe Channel:- It enables inter-process communication (IPC).

MSMQ Channel:- It enables services to inter-operate the MSMQ Applications.

Q5.What are different ways in which WCF can be hosted?

The different hosting techniques are

1.IIS hosting–This is the most commonly used hosting technique.Here IIS is

used as a server and has following

advantages -> starts automatically on the first client request,process recyling.

Disadvantage– It supports only http protocol

2.Self hosting-This is hosting the WCF urself either in console/windows

application also in windows service.

The host process should be running before a client makes a call to servc.

Its easier to debug and deploy.

Lifetime of services can be controlled using Open and Close methods.

WAS hosting(Windows Activation Server hosting)–WAS was introduced

with windows vista and it is shipped with IIS 7.0. it is more powerful than

3.IIS 6.0 as it can support http,tcp and named pipes whereas IIS 6.0 can

support only http.

4.Windows Service Hosting–Here the service can be programmed to start

when the system starts.

Q6.What is the difference WCF and Web services?

Web services can only be invoked by HTTP. While Service or a WCF component can be invoked by any protocol and any transport type. Second web services are not flexible. However, 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.

Q7.What is the Message Layer in WCF?

The message layer specifies the pattern of exchanging data between channels that are used during service communication.

There are two types of channels used in WCF.

Transport layer:- HTTP,Named pipes,TCP and MSMQ are used in transport layer.

Protocol :- WS-Security and WS-Reliability are protocols that used in WCF Applications.

Q8.How transaction works in WCF?

When we say Transaction, it means more than one party will be involved in order to complete one single logical operation. In case of SOA party means service.

Normally WCF transaction follow two faces. In Phase 1 Transaction manager checks whether all services have completed their work and ready to commit. This phase is termed as prepare phase. If it’s done then in Phase 2 actual commit happens which is termed as Commit Phase.

Q9.What is message Contract in WCF?

A Message contract provides control over the simple object access protocol (SOAP).Message that are produced and consumed by WCF. It helps to direct access to the SOAP header and bodies to change the SOAP Message as for your requirement.The most important feature of SOAP Message is interoperability.

>>Read More>>

https://www.mytectra.com/interview-question/wcf-interview-questions-and-answers/