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.

1 comment: