WCF interview questions for fresher/WCF Interview Questions and Answers for Freshers & Experienced

What are the possible ways of hosting a WCF service?

A WCF service can be self-hosting using a console application or Windows Forms applications. Hosting a WCF service in any managed .Net application is called self-hosting. Now the following is the procedure for creating a WCF service and hosting it in a console application. Hosting Environment Requirements:

* Availability: When do you want to be able to reach your service?
* Reliability: What happens when your service somehow breaks? How does this affect other consumers?
* Manageability: Do you need easy access to information about what is happening on the host where WCF services live?
* Versioning: Do you need to support older versions of the service? Do you know who is consuming your services?
* Deployment: What is your deployment model? Are you installing through the Microsoft * Installer process and Visual Studio deployment packages, or is xcopy sufficient?
*State: Are your services stateless? Do you need sessions?

What is Fault Contract in WCF?

Fault Contract provides documented view for error accorded in the service to client. This help as to easy identity the what error has occurred, and where. By default when we throw any exception from service, it will not reach the client side. The less the client knows about what happened on the server side, the more dissociated the interaction will be, this phenomenon (not allowing the actual cause of error to reach client) is known as error masking. By default all exceptions thrown on the service side always reach the client as FaultException, as by having all service exceptions indistinguishable from one another, WCF decouples the client from service.

What are the transactions in WCF? Explain its types too.

-A transaction is a logical unit that defines multiple activities in WCF either pass or fails. The two common types of transactions are – Atomic and Long Running. Two phases of transactions are Prepare Phase and the Commit Phase.

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.

What is "Per Session" instance mode in WCF?

Per session instance mode creates a logical session between service and client and it will be maintained till the end of the session. When client requests from service the session will be created and it is dedicated to the instance for that client and it will be going to the end when client session ends.

What is "Per Call" instance mode in WCF?

When a request has made to service, it creates a new instance of service for each method call and this will be disposed of once the response goes to the client. This whole process is known as per call instance mode.

Explain the term impersonation.

Services often use a technique called impersonation to restrict client access to a service domain's resources. In WCF, impersonation is disabled by default, and services are accessed via the process identity of the WCF service.

Why we need Streaming?

When you have a large amount of data to transfer, the streaming transfer mode in WCF is a feasible alternative to the default behavior of buffering and processing messages in memory in their entirety.

In WCF any receiving message is delivered only once the entire message has been received. What I mean here is that first message is buffered at the receiving side and once it is fully received it gets delivered to the receiving end. The main problem with this approach is that the receiver end is unresponsive while the message is getting buffered. So default way of message handling in WCF is ok for small size messages but for the large size messages, this approach is not good. So to overcome this problem Streaming in WCF come into action.

What is transport in WCF?

The WCF programming model separates endpoint operations (as expressed in a service contract) from the transport mechanism that connects two endpoints. This gives you the flexibility to decide how to expose your services to the network. The transport layer is at the lowest level of the channel stack. A transport sends or receives the serialized form of a message to or from another application. The main transports used in Windows Communication Foundation (WCF) are:

HTTP,
HTTPS,
TCP
named pipes.

What are different ways of exception handling in WCF?

For troubleshooting unexpected problems in applications, exception handling is essential. Exception handling is a feature of object programming languages and it is an error that occurs during execution. In WCF, there are three ways to handle exceptions:
returnUnknownExceptionsAsFaults: Debugging Mode
FaultException: Best Option
IErrorHandler: Only when Fault cannot handle the exception

What do you mean by WCF data service?

WCF Data Services is basically a platform for what Microsoft calls Data Services. Tabular data can be exposed as a set of REST APIs, allowing standard HTTP verbs such as GET, POST, PUT, and DELETE to be used. The OData protocol is used by WCF Data Services for addressing and updating resources.

Explain MEPs in WCF.

MEP (Message Exchange Pattern) is a way of communicating between clients and servers in WCF. MEP is one of the greatest features of WCF. The three types of MEPs supported by WCF are as follows:

Request-Reply: Request-Reply is WCF's default communication pattern.
One-way: Using this pattern means you don't expect to receive a response back from the service after it performs a certain operation.
Duplex: Duplex is a two-way communication way. The duplex MEP is applicable when the client initiates a long-running process with the service and the service requires notification.

What is the goal of transport-level security in WCF?

In WCF, the transport security mechanisms are dependent on the binding and transport that is used. It ensures the message passes securely from the client to the service over a transport medium. This point-to-point security is established using SSL (Secure Socket Layer). Integrity, privacy, and authentication are the goals of transport-level security.

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.

Explain WCF throttling.

Throttling is derived from the keyword throughput, which means work that is performed at specific intervals of time. We can limit the number of instances or sessions created at the application level using the properties like maxConcurrentCalls, maxConcurrentInstances, and maxConcurrentSessions provided by WCF throttling. Performance is boosted by using it.

What are the different address formats of WCF?

Different address format of WCF include:

1. HTTP Address Format: http:// localhost:
2. TCP Address Format: net.tcp://localhost:
3. MSMQ Address Format: net.msmq://localhost:

Name the namespace that is especially required to have access to the WCF service.

To access WCF service, “System.ServiceModel” is used. It provides classes that relate to service models. The namespace contains the types necessary for building WCF services and client applications.

What do you mean by Instance Management?

WCF uses an Instance Management approach to bind a set of messages (client requests) to a set of service instances. The need for Instance Management is crucial since the demands of applications vary too much in terms of scalability, throughput, transactions, queues, and performance. Therefore, one solution does not fit all applications.

Name the different ways to create a WCF client.

There are two different ways to call a WCF service or create a WCF client:

1 . WCF Proxy
2 . Channel factory

What do you mean by SOA?

An SOA (Service-oriented architecture) is an architecture style that enables different applications to be organized as Services. In essence, it determines how communication is possible between two computing entities and how one entity performs functions on behalf of another entity. Rather than being a specific technology or language, SOA is a way to design systems. The purpose of this architecture model is to enhance an enterprise's efficiency, agility, and productivity.

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.

What is WCF Binding and how many of them do you know?

There are three major ways of hosting a WCF services

• 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 Service Host class and the service closes when you call the Close of the Service Host class.

• Host in application domain or process provided by IIS Server.

• Host in Application domain and process provided by WAS (Windows Activation Service) Server.

Name three different types of transaction managers supported by WCF.

Three different types of transaction managers supported by WCF include:

<> Light Weight
<> WS- Atomic Transaction
<> OLE Transaction

What was the code name for WCF?

The code name of WCF was Indigo .

WCF is a unification of .NET framework communication technologies which unites the following technologies:-

NET remoting

MSMQ

Web services

COM+

What are the transactions in WCF? Explain its types too.

A transaction is a logical unit that defines multiple activities in WCF either pass or fails. The two common types of transactions are – Atomic and Long Running. Two phases of transactions are Prepare Phase and the Commit Phase.

What is binding in WCF? Explain its characteristics too.

The Binding will explain to you how will you communicate with the service. There are plenty of protocols to facilitate communication in WCF. These are HTTP, TCP, MSMQ, etc. The characteristics of binding are Protocol, Encoding, or Transport, etc.

What is the need for Addresses when defining service endpoints in WCF?

If you are not sure where to send messages then addresses play an important role here. This is a Uniform Resource Locator (URI) that will identify the location of the receiver. It is similar to the network address and highly useful to send or receive messages. It can be divided into four parts – Scheme, Machine, Port, and path. Each address is unique in itself and finds out the location of the receiver accurately without any error. There are plenty of protocols are used to exchange messages in WCF. These are HTTP, TCP, MSMQ, etc.

How will you define the message contract in WCF?

The objective of the message contract in WCF is to define the structure for the message and how can you perform the serialization. By default, it will take care of SOAP messages based on service requirements. Here is given the general syntax for message contract in compact form – [code] [MessageContract] Public Class AutherRequest { Public String AutherId; } [/code]

What is Message Contract in WCF?

Sometimes complete control over the structure of a SOAP message is just as important as control over its contents (that defined by Data Contracts). This is especially true when interoperability is important or to specifically control security issues at the level of the message or message part. In these cases, you can create a message contract that enables you to specify the structure of the precise SOAP message required.

What do you mean by Data Contract Serializer?

This is the frequently asked WCF Interview Questions in an interview. When the object instance changes into a portable and visible format, that process is known a Serialization and data serialization is also known as Datacontractserilizer.

What are the components of the WCF application?

WCF application consists of 3 components:

WCF Service
WCF Service Host
WCF service client

Explain Tracing in WCF.

Using WCF tracing, you can diagnose data, fault messages, and analyze them. Tracing offers better insight into the application's behavior and flows than debugging. It gives you a detailed account of all application components including faults, code exceptions, system events, and operation calls. By default, WCF tracing is not enabled, therefore it must be enabled by configuring it with the switch value and tracelistener.

What do you mean by service proxy?

WCF proxy classes enable client applications to communicate with services by sending and receiving messages. Communication involves exchanging messages in the form of requests and responses. This will include details such as the Service Path, Protocol Details, etc.

What do you mean by WCF service endpoints?

Endpoints generally provide WCF with instructions on how to construct communication channels at runtime to send and receive messages. It provides the necessary configuration to set up the communication and to create the complete WCF service application.
Endpoint consist of the following three elements:

Address: The address identifies the endpoint and tells potential customers where to find it. In the WCF object model, it is represented by the EndpointAddress class.
Binding: Bindings describe how clients can communicate with an endpoint. Furthermore, it specifies what transport protocol to use, which message format to use, and which web service protocols to use for a particular endpoint.
Contract: Contracts specify what functionality the endpoint provides the client. Furthermore, it provides information about the structure of the various message contents that are intended to be used by the various operations that are exposed to specific endpoints.

Explain Concurrency management.

The following are the different methods of hosting WCF services:
In WCF, concurrency issues can occur when multiple threads access the same resource simultaneously. One request can be handled at a time by the WCF service. With WCF concurrency management, you can control multiple threads within an InstanceContext at any given time using System.ServiceModel.ServiceBehaviorAttribute. It also helps you to configure the number of service instances that can serve multiple concurrent requests.
WCF 4.0 supports three types of concurrency:

* Single Concurrency Mode: In this scenario, the WCF service object is accessible to one request at a time. As a result, only one request can be processed at any given time.
* Multiple Concurrency Mode: In this scenario, the WCF service object can handle multiple requests at any given time in this scenario. In simple words, multiple threads are spawned on the WCF server object to processing requests at the same time.
* Reentrant Concurrency Mode: As described here, the WCF service object is accessible to only one request thread, but this thread may exit the WCF service to invoke another WCF service or may utilize a callback to invoke a WCF client and then reenter without deadlock

How to define a service as REST based service in WCF?

WCF 3.5 provides explicit support for RESTful communication using a new binding named WebHttpBinding.

The below code shows how to expose a RESTful service

[ServiceContract]
interface IStock

{

[OperationContract]

[WebGet]

int GetStock(string StockId);

}

By adding the WebGet Attribute, we can define a service as REST based service that can be accessible using HTTP GET operation.

What is endpoint in WCF?

Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint.

The Endpoint is the fusion of Address, Contract and Binding.

How will you explain the data contract in WCF?

A data contract is a formal agreement between the server and the client between whom data is exchanged securely. It could be defined either implicitly or explicitly based on the requirement. It will define the format, structure, and type of data to be exchanged between parties. It will define the process of how can data be serialized or deserialized. This is a versioning system that helps to manage changes for structural data. [code] [DataContract] Public class cuboidInfo { } [/code] Here, in the example, we have given the general syntax for the data contract. It will provide complete data abstraction at a new level like never before.

What do you mean by contract in WCF? Explain the type of contracts too.

The main objective of defining contracts is to make agree with both client and server for the same operations, structures, data types, etc. This is important to establish secure communication between the two. This is a formal agreement to define the platform neutrality and standards as well as what is done by the services. Here is given most common types of contracts that are frequently used within WCF technology.

<> Service Contract
<> Operation Contract
<> Data Contract
<> Message Contract
<> Fault Contract

How will you define the service contract in WCF?

The Service Contract is a collective mechanism where the capabilities and requirements of service are specified for its consumers. It will explain the list of operations that will be performed by the service when it is executed. It will define the data types, protocols, and operation locations for the service. Defining a service contract for WCF is not easy but developers should have the right skills and experience to complete this task.

What do you mean by SOA? Do web services come under SOA?

SOA means a service-oriented architecture that helps to organize apps as Services. This is a group of methods that define the business logic and helps to connect with DB and other services quickly. Take an example of the restaurant where you go and order food. Your order will go from the counter to the kitchen and it is served on your table finally.

The benefits of SOA architecture - Independent, Self-contained, self-explanatory, etc. SOA Architecture – It consists of four key abstractions – an application front end, a service repository, a service bus, a service, etc. Web services are not SOA but preferable standards to achieve the SOA.

What are the benefits or advantages of WCF Technology?

* The framework can be configured to work independently with SOAP or RSS.
* This a popular communication technology that offers remarkable performance when compared to other Microsoft specifications.
* This framework is suitable for secure communication, data transmission, and even speed can be optimized. It is exchanging data in binary format to decrease the latency.
* This is a distributed management system that is applicable to almost all applications that are developed with WCF.

What is the need for WCF services for your business?

1. It is used to exchange messages in XML format with the help of HTTP protocol to maintain interoperability.
2. WCF uses remote services to exchange messages in binary format with the help of TCP protocol to maintain performance.
3. A service to exchange data securely over the network in real-time.

Where we can host WCF services?

Every WCF services must be hosted somewhere. There are three ways of hosting WCF services.

They are

* IIS
* Self Hosting
* WAS (Windows Activation Service)

What is address in WCF and how many types of transport schemas are there in WCF?

Address is a way of letting client know that where a service is located. In WCF, every service is associated with a unique address. This contains the location of the service and transport schemas.

WCF supports following transport schemas

HTTP

TCP

Peer network

IPC (Inter-Process Communication over named pipes)

MSMQ

The sample address for above transport schema may look like

http://localhost:81

http://localhost:81/MyService

net.tcp://localhost:82/MyService

net.pipe://localhost/MyPipeService

net.msmq://localhost/private/MyMsMqService

net.msmq://localhost/MyMsMqService

What is service and client in perspective of data communication?

A service is a unit of functionality exposed to the world.

The client of a service is merely the party consuming the service.

Write the core components of WCF?

The three core components of WCF are as follows:

1. Service class: In the runtime layer, you will find the behaviors that occur only when a service is actually running, i.e., the runtime behaviors of the service. Throttling is used to control the number of messages processed that can be altered if the service grows to a preset limit.
2. Endpoint: WCF Service makes available a set of endpoints. All Endpoints are portals through which users are able to communicate with the outside world. Endpoints are composed of three components: Address, Binding, and Contract.
3. Hosting Environment: It is the host application that is responsible for controlling the service's lifetime. Self-Hosting or management of services can be done by the existing hosting process.

What are the benefits of WCF?

WCF has the following benefits:

* Performs better than other Microsoft specifications.
* Secure communication, data transmission, or even speed optimization can be achieved.
* Decrease the latency by exchanging data in binary format.
* Comparatively more reliable and secure than ASMX Web services.
* Using the security model and altering the binding does not require a lot of coding changes.
* A few changes to the configuration file will meet your needs.
* Ensures interoperability between services.
* Multiple hosting options are available such as IIS, WAS, self-Hosting.

Explain what is SOA?

SOA stands for **service-oriented architecture. Service Oriented Architecture is an architectural approach in software development where the application is organized as "Services". Services are a group of methods that contain the business logic to connect a DB or other services. For instance you go to a hotel and order food. Your order first goes to the counter and then it goes to the kitchen where the food is prepared and finally the waiter serves the food.

Some important characteristics of Service Oriented Architecture

* SOA services should be independent of other services. Altering a service should not affect the client calling the service.
* Services should be self-contained. Services should be able to define themselves (in the Web Service Description Language (WSDL)). It should be able to tell the client what all of the operations it does, what are all the data types it uses and what kind of value it will return.

What is WCF?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. 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. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data.

Search
R4R Team
R4R provides WCF Freshers questions and answers (WCF Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,WCF interview questions for fresher,WCF Freshers & Experienced Interview Questions and Answers,WCF Objetive choice questions and answers,WCF Multiple choice questions and answers,WCF objective, WCF questions , WCF answers,WCF MCQs questions and answers Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for WCF fresher interview questions ,WCF Experienced interview questions,WCF fresher interview questions and answers ,WCF Experienced interview questions and answers,tricky WCF queries for interview pdf,complex WCF for practice with answers,WCF for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .