Software Architecture – Interview Questions for Windows Communication Foundation-WCF Architect

July 23, 2010

Let suppose you are invited for an interview as Windows Communication Foundation-WCF Architect.

WCF is a very hard topic to handle. It is very hard to cover all features of WCF in detail, but I have compiled few questions from MSDN related to such interview.

Enjoy……and Best of luck for interview…:)


What is Endpoints?

Endpoints provide clients access to the functionality offered by a WCF service.

Each endpoint consists of four properties:

  • An address that indicates where the endpoint can be found.
  • A binding that specifies how a client can communicate with the endpoint.
  • A contract that identifies the operations available.
  • A set of behaviors that specify local implementation details of the endpoint.


What is Endpoint Address?

The address uniquely identifies the endpoint and tells potential consumers of the service where it is located. It is represented in the WCF object model by the EndpointAddress class. An EndpointAddress class contains:

  • A Uri property, which represents the address of the service.
  • An Identity property, which represents the security identity of the service and a collection of optional message headers. The optional message headers are used to provide additional and more detailed addressing information to identify or interact with the endpoint.


What is Endpoints Binding?

Binding: The binding specifies how to communicate with the endpoint. This includes:

  • The transport protocol to use (for example, TCP or HTTP).
  • The encoding to use for the messages (for example, text or binary).
  • The necessary security requirements (for example, SSL or SOAP message security).


What is Endpoints Contracts?

The contract outlines what functionality the endpoint exposes to the client. A contract specifies:

  • What operations can be called by a client.
  • The form of the message.
  • The type of input parameters or data required to call the operation.
  • What type of processing or response message the client can expect.


What is Endpoints  Behaviors?

Behaviors: You can use endpoint behaviors to customize the local behavior of the service endpoint. Endpoint behaviors achieve this by participating in the process of building a WCF runtime.

What are different system provided system bindings?

  • BasicHttpBinding
  • WSHttpBinding
  • WS2007HttpBinding
  • WSDualHttpBinding
  • WSFederationHttpBinding
  • WS2007FederationHttpBinding
  • NetTcpBinding
  • NetNamedPipeBinding
  • NetMsmqBinding
  • NetPeerTcpBinding
  • MsmqIntegrationBinding


What is difference between Service Binding and Client Binding?

What are different ways to define binding?

Two ways as:

  • Via Configuration file
  • Via Code


What is difference b/w System-Provided Bindings ,  Custom Bindings and Creating User-Defined Bindings?

What is Service Contract?

A service contract is a statement that provides information about:

  • The grouping of operations in a service.
  • The signature of the operations in terms of messages exchanged.
  • The data types of these messages.
  • The location of the operations.
  • The specific protocols and serialization formats that are used to support successful communication with the service.

What are different Contract types?

Different types of message-exchange patterns (MEPs) that contracts are as:

  • Request-reply
  • One-way
  • Duplex.


What are Request-Reply Services?

Clients make calls (Request) to service operations and wait for a response from the service.

Calls to a service operation either synchronously or asynchronously.

Default type Service Contract Operation.

Example for Service Contract ?

using System.ServiceModel;


public interface ICalculator



// It would be equivalent to write explicitely:

// [OperationContract(IsOneWay=false)]

int Add(int a, int b);


int Subtract(int a, int b);

int Multiply(int a, int b)


What are One-Way Services?

With a one-way operation, only one message is transmitted. The receiver does not send a reply message, nor does the sender expect one.


    void Add(double n1, double n2);

What is A duplex service contract?

A duplex service contract is a message exchange pattern in which both endpoints can send messages to the other independently.

Duplex communication occurs when a client connects to a service and provides the service with a channel on which the service can send messages back to the client.

[ServiceContract(Namespace = “http://Microsoft.ServiceModel.Samples”, SessionMode=SessionMode.Required,                 CallbackContract=typeof(ICalculatorDuplexCallback))]

public interface ICalculatorDuplex


    [OperationContract(IsOneWay = true)]

    void Clear();

    [OperationContract(IsOneWay = true)]

    void AddTo(double n);


public interface ICalculatorDuplexCallback


    [OperationContract(IsOneWay = true)]

    void Equals(double result);

    [OperationContract(IsOneWay = true)]

    void Equation(string eqn);


In constructor of service contract implementation as:

ICalculatorDuplexCallback callback = null;


callback = OperationContext.Current.GetCallbackChannel<ICalculatorDuplexCallback>();


public void AddTo(double n)


        result += n;

        equation += ” + ” + n.ToString();



Define session, Instancing and Concurrency for WCF?

A session is a correlation of all messages sent between two endpoints.

Instancing refers to controlling the lifetime of user-defined service objects and their related T:System.ServiceModel.InstanceContext objects.

Concurrency is the term given to the control of the number of threads executing in an InstanceContext at the same time.

What are the mode of instancing in WCF?

  • PerCall: A new InstanceContext (and therefore service object) is created for each client request.
  • PerSession: A new InstanceContext (and therefore service object) is created for each new client session and maintained for the lifetime of that session (this requires a binding that supports sessions).
  • Single: A single InstanceContext (and therefore service object) handles all client requests for the lifetime of the application.


What is SessionMode in WCF?

System.ServiceModel.SessionMode enumeration to specify whether the contract:

  • Requires a session.
  • Allows a client to establish a session.
  • Prohibits a session.


What are the concurrency modes?

  • Single: Each instance context is allowed to have a maximum of one thread processing messages in the instance context at a time. Other threads wishing to use the same instance context must block until the original thread exits the instance context.
  • Multiple: Each service instance can have multiple threads processing messages concurrently. The service implementation must be thread-safe to use this concurrency mode.
  • Reentrant: Each service instance processes one message at a time, but accepts re-entrant operation calls. The service only accepts these calls when it is calling out through a WCF client object.


What are different Transport in WCF?

HTTP, TCP, and named pipes. WCF also includes a message queuing (also known as MSMQ) transport.

When to Use HTTP Transport in WCF?

When to Use the TCP Transport in WCF?

When to Use the Named Pipe Transport in WCF?

What are Decision Points for Choosing a Transport, Explain each?

  • Diagnostics
  • Hosting
  • Inspection
  • Latency
  • Reach
  • Security
  • Throughput
  • Tooling


What is Message Encoder and what are different options for message encoders in WCF?

Binary, Text, and Message Transmission Optimization Mechanism (MTOM).

How to Choose a Message Encoder in WCF, explain each?

  • Inspection
  • Reliability
  • Simplicity
  • Size
  • Streaming
  • 3rd Party Tool Support
  • Interoperability


What are different message transfer modes?

  • Buffered transfers hold the entire message in a memory buffer until the transfer is complete. A buffered message must be completely delivered before a receiver can read it.
  • Streamed transfers expose the message as a stream. The receiver starts processing the message before it is completely delivered.

The binding element has a TransferMode property that can be set to Buffered, Streamed, StreamedRequest, or StreamedResponse.

What are different Hosting options for WCF Service?

A service can be hosted by Internet Information Services (IIS), Windows Process Activation Service (WAS), a Windows service, or by a managed application—this option is often referred to as self hosting”.

Differentiate b/w service contract, operation contract, message contract, fault contract and data contract?

Service contract

The service contract ties together multiple related operations into a single functional unit. The contract can define service-level settings, such as the namespace of the service, a corresponding callback contract, and other such settings. In most cases, the contract is defined by creating an interface in the programming language of your choice and applying the ServiceContractAttribute attribute to the interface. The actual service code results by implementing the interface.

Operation contract

An operation contract defines the parameters and return type of an operation. When creating an interface that defines the service contract, you signify an operation contract by applying the OperationContractAttribute attribute to each method definition that is part of the contract. The operations can be modeled as taking a single message and returning a single message, or as taking a set of types and returning a type. In the latter case, the system will determine the format for the messages that need to be exchanged for that operation.

Message contract

A message contract describes the format of a message. For example, it declares whether message elements should go in headers versus the body, what level of security should be applied to what elements of the message, and so on.

Fault contract

A fault contract can be associated with a service operation to denote errors that can be returned to the caller. An operation can have zero or more faults associated with it. These errors are SOAP faults that are modeled as exceptions in the programming model.

Data contract

The data types a service uses must be described in metadata to enable others to interoperate with the service. The descriptions of the data types are known as the data contract, and the types can be used in any part of a message, for example, as parameters or return types. If the service is using only simple types, there is no need to explicitly use data contracts.

What is Reliable Sessions?

A reliable session implements the WS-ReliableMessaging protocol and an in-memory transfer window to mask SOAP message-level failures and re-establishes connections in the case of transport failures.

Which Bindings support reliable Session?

The system-defined bindings that support and enable a reliable session by default include:

  • WSDualHttpBinding

The system-provided bindings that support a reliable session as an option but do not enable one by default include:

  • WSHttpBinding
  • WSFederationHttpBinding
  • NetTcpBinding


When to use reliable Session?

  • SOAP intermediaries, such as SOAP routers.
  • Proxy intermediaries or transport bridges.
  • Intermittent connectivity.
  • Sessions over HTTP.


Identify few business cases for Queue implementation in WCF?

Explain MSMQ implementation in WCF?

What is Dead-Letter Queue Programming?

What is Poison Message Queue Programming?


How Transactions are implemented in WCF?

WCF implements support for the WS-AtomicTransaction (WS-AT) protocol that enables WCF applications to flow transactions to interoperable applications, such as interoperable Web services built using third-party technology. WCF also implements support for the OLE Transactions protocol, which can be used in scenarios where you do not need interop functionality to enable transaction flow.

What is MSDTC?

The Microsoft Distributed Transaction Coordinator (MSDTC) is a transaction manager that provides support for distributed transactions.


How to specify ServiceModel Transaction Attributes?

Three standard System.ServiceModel attributes that enable you to configure the behavior of transactions for a WCF service:

  • TransactionFlowAttribute
  • ServiceBehaviorAttribute
  • OperationBehaviorAttribute


How to specify ServiceModel Transaction details in Configuration?

Provides three attributes for configuring transactions for a service: transactionFlow ( in binding configuration), transactionProtocol( in binding configuration), and transactionTimeout(in the behavior element of the configuration file).

What Controls Transaction Settings in WCF?

Transaction flow settings are generated for a service endpoint as a result of the intersection of the following three values:

  • The TransactionFlowAttribute attribute specified for each method in the service contract.
  • The TransactionFlow binding property in the specific binding.
  • The TransactionFlowProtocol binding property in the specific binding.


What is usage of wsatConfig.exe?

wsatConfig.exe is used to configure WS-AT settings.


Define followings:

  • WS-*
  • WCF client
  • transport with message credential security mode
  • transport security mode
  • terminating operation
  • system-provided bindings
  • service operation
  • service contract
  • service
  • self-hosted service
  • security
  • operation contract
  • metadata
  • message security mode
  • message contract
  • message
  • instancing model
  • initiating operation
  • hosting process
  • hosting
  • fault contract
  • endpoint
  • data contract
  • contract
  • channel
  • binding element
  • binding
  • behavior
  • application endpoint
  • address