Thursday 23 February 2017

WCF interview question Part 1

1. Ques: What is WCF ? What are the advantages of WCF ?
Answer:
  • WCF stands for Windows Communication Foundation introduce by Microsoft in .NET Framework 3.5 in Visual Studio .NET 2008.
  • WCF is Microsoft's unified programming model for building service-oriented application.
  • It is a framework for building service-oriented applications.
  • Using WCF we can send data as asynchronous messages from one service endpoint to another. 
  • It is a combination of multiple existing .NET Technologies like asmx, .NET Remoting, Enterprise Services, WSE and MSMQ.
Advantages of WCF
  • Interoperability: A single platform used to exchange information.
  • Security and Reliability: Security in the form of auditing, authentication, authorization, confidentiality and integrity of messages.
  • Speed:Its faster than Web services

2. Ques: What are the main components of WCF Service?
Answer:
Three main component in wcf services
Service class : A wcf Service class implements some service as a set of methods.
Hosting enviroment:  wcf supports four types of hosting, IIS, Windows Process Activation Services (WAS), self-hosting and Windows Services.
End Point : Endpoints provide clients access to the functionality offered by a WCF service.
Each endpoint consists of four properties:
  • Address: An address that indicates where the endpoint can be found. 
  • binding: A binding that specifies how a client can communicate with the endpoint. 
  • contract: A contract that identifies the operations available.
3. Ques:  How many way we can host a WCF service?
Answer:
we can hosting a WCF Service in four way:
  • Self-Hosting
  • Windows Service
  • Internet Information Services (IIS)
  • Windows Activation Services (WAS)
Self-Hosting:-
In self hosting the WCF service hosted within the project solution (Windows application or web application ).
To implement self-hosting we have to include System.Service.Model.ServiceHost namespace.
advantages of self-hosting:
  • Is easy to use: With only a few lines of code you have your service running.
  • Is flexible: You can easily control the lifetime of your services through the Open() and Close() methods of ServiceHost<T>.
  • Is easy to debug: Debugging WCF services that are hosted in a self-hosted environment provides a familiar way of debugging, 
  • Is easy to deploy: 
  • Supports all bindings and transports: 

4. Ques: What is Address, Binding And Contract in wcf ?
Answer:-
Address: The address uniquely identifies the endpoint and tells potential consumers of the service where it is located.
  • A Uri property, which represents the address of the service.
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).
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.

5. Ques: What is Binding in WCF ? What are the types of binding?
Answer:-
Binding describes how a client is going to communicate to WCF service. Binding is used as per client need. It supports different types of protocol to communicate with client and different types of encoding to transfer the data over the internet. So, basically binding is nothing but it is a way of communication between client and service as per client need.

Different type of binding supported by wcf:-
  • BasicHttpBinding: Basic Web service communication. No security by default.
  • WSHttpBinding: Web services with WS-* support. Supports transactions.
  • WSDualHttpBinding: Web services with duplex contract and transaction support.
  • WSFederationHttpBinding: Web services with federated security. Supports transactions.
  • MsmqIntegrationBinding: Communication directly with MSMQ applications. Supports transactions.
  • NetMsmqBinding: Communication between WCF applications by using queuing. Supports transactions.
  • NetNamedPipeBinding: Communication between WCF applications on same computer. Supports duplex contracts and transactions
  • NetPeerTcpBinding: Communication between computers across peer-to-peer services. Supports duplex contracts
  • NetTcpBinding:Communication between WCF applications across computers. Supports duplex contracts and transactions

No comments:

Post a Comment

Thank you for comment