WCF Interview Questions part 2

In the WCF Interview Question part 1 we have seen very basic interview question on the WCF for the beginners. In this article I have tried to have interview question answers for the advanced WCF topics

Q. Can we overload methods in the WCF?
A. Yes we can overload the methods in the WCF for that we need to use the Name property of the OperationContract to give different method name in the proxy.
[ServiceContract]
Public Interface Sample
{
[OperationContract(Name = "IntergerOverload")]
Int OverloadMethod(int paramA, int paramB)

[OperationContract(Name = "DoubleOverload")]
double OverloadMethod(double paramA, double paramB)
}
Q. What is host factory in the WCF?
A. Using Service host factory we can create service host dynamically as request comes in and we need to use ServiceFactory class for this purpose.

Q.
In the WCF service can we pass.Net exception information to the client?
A. Service will not return the exception information directly to the client but WCF service can pass it as the SOAP message.

Q. How can we set concurrency mode in the WCF?
A. Concurrency mode can be specified by ServiceBehavior attribute on the implementation class
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Single)]
Public class SamplServiceImpl : ISample{
//Implementation Code
}
There are 3 possible values of ConcurrencyMode enumeration
  • Single
  • Reentrant
  • Multiple

Q. Which protocol used for the platform independent communication in WCF?
A. SOAP(Simple Object Access Protocol) is used in WCF for the platform independent communication in the WCF.

WCF Interview Questions part 1

Q. What is WCF?
A. WCF stands for Windows Communication Foundation. It is a Software development kit for developing services on Windows. WCF is introduced in .NET 3.0. in the System.ServiceModel namespace. WCF is based on basic concepts of Service oriented architecture (SOA)

Q. What is endpoint in WCF service?
A. The endpoint is an Interface which defines how a client will communicate with the service. It consists of three main points: Address,Binding and Contract.(Also knows as ABC of WCF)

Q. Explain Address,Binding and contract for a WCF Service?
A.
Address:Address defines where the service resides.
Binding:Binding defines how to communicate with the service.
Contract:Contract defines what can be done with the service.

Q. What are the types of binding available in WCF?
A. A binding is identified by the transport it supports and the encoding it uses. Transport may be HTTP,TCP etc and encoding may be text,binary etc. The popular types of binding may be as below:
a)BasicHttpBinding
b)NetTcpBinding
c)WSHttpBinding
d)NetMsmqBinding

Q. What are the types of contract available in WCF?
A.
a)Service Contract:Describes what operations the client can perform.
b)Operation Contract : Defines the method inside Interface of Service.
c)Data Contract:Defines what data types are passed
d)Message Contract:Defines wheather a service can interact directly with messages


Q. What is the proxy for WCF Service?
A. A proxy is a class by which a service client can Interact with the service by calling different methods.We can create proxy by using svcutil.exe

Q. What is the basic difference between WCF Service and Web Service?
A. WCF service support both http and tcp protocol while web service support only http protocol.