Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Name the different ways to create a WCF client.

Answer»

There are two different ways to CALL a WCF service or CREATE a WCF CLIENT:

  • WCF PROXY 
  • Channel factory
2.

What do you mean by SOA?

Answer»

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.

3.

Name three different types of transaction managers supported by WCF.

Answer»

Three different types of transaction managers SUPPORTED by WCF include: 

  • LIGHT WEIGHT 
  • WS- Atomic Transaction 
  • OLE Transaction 
4.

What do you mean by Security Implementation?

Answer»

Since, WCF's support various protocols, such as TCP, HTTP, and MSMQ, the user must ENSURE that the necessary steps are taken to safeguard messages, and also establish security policies for authenticating and authorizing CALLS. WCF provides an easy and rich CONFIGURATION environment for secure messaging. WCF supports the following security models:  

  • Message Security: This application uses the WS-Security specification to encrypt messages. Messages are now securely encrypted using certificates and can be sent over any port using PLAIN HTTP.  
  • Transport Security: This is a protocol that implements security, so it only works point to point. Since security is protocol-dependent, security support is limited and confined to the standard protocol security limitations.
  • TransportWithMessageCredential: It can be referred to as a mixture of both Message and Transport security implementation. Credentials are sent with the message, and the transport layer provides message protection and server authentication. 
5.

Explain Tracing in WCF.

Answer»

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. 
WCF Tracing basically involves the following four steps:

6.

What do you mean by service proxy?

Answer»

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.

7.

Name the isolation levels that are provided in WCF

Answer»

WCF offers the following isolation or transaction levels: 

  • Read UNCOMMITTED: This is also called the Dirty isolation level. It states that the data can be both read and modified during the transaction. This is the lowest level of isolation.  
  • Read Committed: It is commonly referred to as the DEFAULT. It states that data may be modified, but it may not be read during the transaction. 
  • REPEATABLE Read: This stops the use of dirt reads and non-repeatable reads. It states that Data can be read but not modified during the transaction. However, new data can be added.  
  • Serializable: It is also CONSIDERED a RESTRICTIVE level. It states that data can be read, but there are no modifications or additions of new data allowed until the transaction has been completed.  
8.

What do you mean by WCF service endpoints?

Answer»

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

Explain Concurrency management.

Answer»

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

Write different ways of hosting a WCF service.

Answer»

The FOLLOWING are the DIFFERENT methods of hosting WCF services:

  • Self-Hosting: It refers to hosting a WCF SERVICE within a managed application. The LIFECYCLE of Host processes is always managed by developers. In order to implement self-hosting, we must include the System.Service.Model.ServiceHost namespace. 
  • Windows Services Hosting: It refers to hosting a WCF service within Windows service. WCF Service lifecycle can be controlled by Service Control Manager. It can, however, be hosted on any version of Windows. 
  • IIS (Internet Information Service Hosting):  Hosting our service under IIS allows us to use all of its features, such as process recycling, ideal shutdown, etc. HTTP transport is the only MECHANISM supported by IIS-hosted services. 
  • WAS (Windows Activation Service Hosting): It is a generalization of IIS features that supports transport protocols other than HTTP. Through the listener adapter interface, WCF communicates activation requests received over non-HTTP protocols supported by WCF, like TCP, named pipes, and Message Queuing. 
11.

What are the types of contracts in WCF?

Answer»

The WCF includes five types of contracts as follows:  

  • Service contract: It describes what operations the service exposes to the OUTSIDE world. This is the interface to the WCF service and it lets the outside world KNOW what the service can do.

Example: 

[ServiceContract]interface IMyContract{[OperationContract]string MyMethod();}class MyService : IMyContract{public string MyMethod(){return "Namaste";}
  • Operation contract: It specifies the method by which client and server exchange information. It ALSO states what functionality the client will receive, such as adding, subtracting, etc.

Example: 

[ServiceContract] interface ICustomer { [OperationContract] Response AddNew(string CUSTOMERNAME); Response Delete(int customerID); }
  • Data contract: It is a formal agreement between the server and the client that involves high-level security for the exchange of data between the two. Format, STRUCTURE, and type of data exchanged between parties are defined by it. Serialization and deserialization of data are also described.

Example: 

[DataContract]class Person{ [DataMember] public string ID; [DataMember] public string Name;} [ServiceContract] interface IMyContract{ [OperationContract] Person GetPerson(int ID);}
  • Message contract: A message contract specifies the structure of the message and how the serialization should be performed. With it, you control everything from the content of the SOAP header to the structure of the SOAP body.

Example: 

[ServiceContract] interface ICuboidService { [OperationContract] [FaultContract(typeof(CuboidFaultException))] CuboidDetailResponse CalculateDetails1(CuboidInfoRequest cInfo); [OperationContract] [FaultContract(typeof(CuboidFaultException))] CuboidDetail CalculateDetails2(CuboidInfo cInfo); [OperationContract] [FaultContract(typeof(CuboidFaultException))] CuboidDetail CalculateDetails3(int nID, CuboidDimension cInfo); } 
  • Fault contract: It generally specifies how errors or defaults that are raised by the service are handled and propagated to clients. There can be zero or more fault contracts associated with an operation contract.

Example:  

[ServiceContract]interface IMyContract{ [FaultContract(typeof(MyFaultContract1))] [FaultContract(typeof(MyFaultContract2))] [OperationContract] string MyMethod(); [OperationContract] string MyShow();}
12.

Explain the WCF Contract.

Answer»

Basically, WCF CONTRACTS are standardized, platform-neutral descriptions of what the service does.  Contracts mainly serve to enable clients and services to agree on what sort of operations and STRUCTURES they will USE for communication. One of the components of a WCF ENDPOINT is the contract, which contains INFORMATION about the service. In addition, the contract helps serialize service information.

13.

Write the difference between WCF and Web Services

Answer»
WCFWeb Services
DataContractSerializer is used by WCF to determine which fields are serialized into XML.XMLSerializer is used by Web services that do not determine which fields are serialized into XML. 
HTTP, TCP, and MSMQ are other protocols supported by WCF that can be extended to provide a comprehensive solution, ENSURE transactions, and provide a reliable experience. HTTP and HTTPS during communication is the only protocol supported by Web services.
MTOM, XML, and BINARY message encoding are supported.XML and MTOM (Message Transmission Optimization Mechanism) message encoding is supported.  
Hosting options include IIS, Windows activation services, self-hosting, and Windows services. Hosting is only possible in IIS. 
Compared to Web Services, WCF is faster and more reliable.WCF is faster and more reliable than Web Services.
WCF services are defined by the ServiceContract and OperationContract attributes. Web services are defined by WEBSERVICE and WebMethod attributes.
RESTFUL SERVICE is supported, but with limitations. It is perfect for building RESTFUL services. 
14.

Write the core components of WCF?

Answer»

The three core components of WCF are as follows: 

  • 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. 
  • 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.  
  • 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. 
15.

Write some WCF features?

Answer»

WCF features include: 

  • Offers support for service-oriented architecture.  
  • Supports MULTIPLE transport methods and encoding options.
  • Provide support for multiple message patterns.
  • Simpler configuration files.
  • Provide UDP endpoint support.
  • Provides support for publishing service metadata USING industry-standard formats such as XML Schema, WS-Policy, WSDL, etc.
  • Provides support for data contracts.
  • Support the creation of durable messages.
  • Provide RELIABLE and queued messages.
  • Support for AJAX and Rest. 
  • Uses modern interface standards for WEB service interoperability.
16.

What are the benefits of WCF?

Answer»

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

Why should one use WCF services?

Answer»

Here are some reasons to use WCF services:

  • Easy to use, and is flexible as well.  
  • Windows activation service, IIS, and self-hosting options are available. 
  • PROVIDES support for multiple protocols INCLUDING HTTP, WS-HTTP, TCP, P2P, MSMQ, and named pipes.   
  • Use remote service to exchange messages in binary format using TCP PROTOCOL for maximizing the performance.  
  • Uses chat to communicate with people or to exchange data. 
  • To monitor the service, it provides data such as a traffic REPORT.   
  • Security services that process the transaction.   
  • Used to exchange messages in XML format via an HTTP protocol in order to maintain interoperability.  
  • Real-time data exchange using secure networks.