Wednesday 9 November 2011

WCF Interview Questions And Answers

Here, some common WCF interview questions which asked by the interviewer. 

Explain briefly about WCF?
WCF is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is latest service oriented technology. Interoperability is fundamental characteristic of WCF. WCF is combined feature of Web Service, Remoting, MSMQ, and COM+. WCF provides a common platform for all .NET communication.

What are different technologies involved in WCF?

There are mainly five technologies involved in WCF, these are :
  1. WSE [WS*] - Protocol Support.
  2. Messaging  - Message oriented programming.
  3. .Net Remoting - Extensibility location transparency.
  4. Enterprise Service - Attribute based programming.
  5. ASMX - Interop with other platforms.
What are advantages of WCF?

Advantages of WCF are :
  1. WCF is interoperable with other services but .Net Remoting requires client and service in .Net.
  2. WCF service provides better reliability and security as compare to Web Services.
  3. In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small change in the configuration will make your requirement.
Brief about WCF Hosting?
There are three ways of hosting WCF service :
Self Hosting
IIS Hosting
WAS(Windows Activation Service)
Explain address and all types of address in WCF?
Address describes where WCF service is hosted. Address is URL that client uses to connect to desired service.
Here is an example :

What is Binding in WCF?
 

Binding describes how client will communicate with services. There are different protocols available to communicate to client. Binding has several  characteristics :

Transport - Define base protocol to be used like HTTP, Named Pipes, TCP and MSMQ. 

Encoding(Optional) - Three types of encoding available - Text, Binary or Message Transmission Optimization Mechanism(MTOM). MTOM is interoperable message format that allows the effective transmission of attachments or large message. 

Protocol(Option) - Defines information to be used in Binding such as security transaction or reliable messaging capability.

What are types of Binding available in WCF? 
BasicHttpBinding It uses SOAP over HTTP.
WsHttpBinding It uses SOAP over HTTP, it also supports reliable message transfer.
NetTcpbinding It uses SOAP over TCP, but server and client should be in .Net.
NetNamedPipesBinding It uses SOAP over Named Pipes.

Explain contract and all types of contract in WCF?
 
Contract is platform-neutral and standard way of describing what services does. In WCF, all services are exposed as contract. There are four types of contracts :
Service Contract It describes operation provided by service. A service should contain at least one service contract. Service Contract is defined by using [ServiceContract] attribute , it is similar to [WebMethod] of Web Services.

Data Contract It describes data exchange between service and client. Data Contract is defined using [DataContract] and [DataMember] attribute.
Message Contract It transfers information from service to client. WCF uses SOAP message format for communication.
Fault Contract It handles and convey error message to the client when service get error.
What is concept of endpoint in WCF?
WCF service expose endpoints by which service is available to client.Endpoint is nothing but consists of ABC that is Address, Binding and Contract.

What is WCF Runtime?

WCF  runtime is set of objects for sending and receiving message.

What is Message in WCF?

WCF message is the unit of data exchange between client and service. It consists of several parts, including a body and header.

Difference between WCF and Web Service?
 

1) Web Services support hosting in IIS whereas WCF support hosting in IIS, WAS and Self-hosting.
2) Web Services can be invoked by Http whereas WCF service can be invoked by Http, Tcp, Named Pipes, MSMQ.
3) WCF Services are more reliable and secure as compare to Web Services.
4) WCF Services are more flexible as we make a new version of service we just have to expose a new endpoint.
5) In Web Service, [WebMethod] attribute specifies the method exposed to client. In WCF [OperationContract] attribute represents the method.

What is Service Host?

Service Host object is in process of  hosting the WCF service and registering endpoints. It loads the service configuration  endpoints, apply the settings. System.ServiceModel.ServiceHost namespace holds this object. This object is created while self hosting the WCF service.

There is scenerio, when one client has to access service SOAP using Http and other client have to access Binary using TCP, how can you acheive?

This can be acheived by adding extra endpoint in configuration file.

<endpoint address="http://locahost:8090/Service" contact="IMathService" binding="wsHttpBinding"/>
<endpoint address="net.tcp://locahost:8080/Service" contact="IMathService" binding="netTcpBinding"/>




  

No comments:

Post a Comment