1. For what purpose WCF is used in your current project?
Answer: Be specific to your answer. Interviewer is trying to understand your understanding on technology as well your interest on your project. Don't try to explain the features of WCF but just give specific requirement for which WCF was chosen in your project.
2. What is binding in WCF?
Answer: Here, don't just answer "Binding defines How part of a service". Try to answer with practical aspect and elaborate it. Binding is an attribute of endpoint, used to specify communication details for a WCF service using 3 elements- transport protocol, messageencoding, and security. This binding object is comprised of several binding-elements that are correspondent to a particular channel-stack of a channel. Our specified details in these binding elements are evaluated by service-runtime whenever an endpoint is constructed. There are many system provided bindings ready for our use. We can customize the behavior of a binding by customizing/changing its properties. If these system provided bindings are not fit for our service, we can create our own binding using "CustomBinding" class.
3. So, how many bindings are there? Have you ever used netMsmqBinding or netNamedPipeBinding?
Answer: Be prepared for this question as it covers your understanding on different bindings. I would recommend you to go through this MSDN link to understand in which scenario you should pick which binding.
4. See, my hosted service is chargeable and I want to track the record that who has called/ accessed my service how many time, how can I do it?
Answer : With this question, interviewer just wanted to know whether you are aware about WCF Extensibility or not. WCF Extensibility is a great feature that enable us to customize & manage service calls. For this question, the answer is: "Parameter Inspector" extension point is used to check and manage WCF service calls. In that we can use BeforeCall() and AfterCall() methods. Parameter Inspector is a WCF extension point. We can inject it in WCF pipeline at client side or server side where we want to validate or customize the call. We can check, modify and reject the call at both places.
Somewhere, you may be ask with a different name "Interceptors in WCF". Interceptor in WCF is nothing but a component that we can plugged into any pipeline stage of WCF.
5. I want to restrict the concurrent access of my service to limited users, how can I do that? Where this setting is done?
Answer: WCF provide us a good way of extensibility to customize various WCF capabilities. We can customize Encoding message, Intercepting parameters etc. and extend the behaviour. Throttling behaviour of service plays an important role and can be set behaviour properties according to our business needs. Below are three important properties for optimizing our WCF service behaviour
- maxConcurrentCalls limits the total number of calls that can currently be in progress across all service instances. The default is 16.
- maxConcurrentInstances limits the number of InstanceContext objects that execute at one time across a ServiceHost. The default is Int32.MaxValue.
- maxConcurrentSessions limits the number of sessions a ServiceHost object can accept. It is a positive integer that is 10 by default.
<behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances ="100" maxConcurrentSessions ="200"/> </behavior>
6. How session management is done in WCF?
Answer: In WCF, session management is quite different than asp.net. In asp.net, session is manage & maintained at server but in WCF, a session is initiated /terminated by client application. Client application get processed message from server within a session that was initiated by it. This session can be used as an extensibility point by server application. Since, it is not maintained at server side, whatever messages are received by service at server, get processed in the order they reached. Also, in asp.net, we have data store facility for session (session variables) but this facility is not available in WCF. A service contract is required to be decorated with SessionMode attribute for session handling setting.
7. How WCF service is secured?
Answer : Refer MSDN - Securing Services
8. Is there any way to give service access permission to role specific user group?
Answer :
WCF provides us the Role Based Authentication mechanism that can be used for setting service access permission for a specific group. To make it work, we need to do some settings in web.config file as well we need to decorate our those services on which we want to implement this access security.
It can be done in 3 simple steps as :
1) Enable “aspNetCompatibilityEnable”
2) Then, we need to specify the Group for which we want to apply security in web.config as:
3) And finally specify the security with class that implement your service. This decoration of service is require because, asp.net Compatibility Mode is set to false by default. RequirementMode is set to Allowed.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
This asp.net compatibility mode setting is done to use ASP features like identity impersonation. This setting applies at the application level (through root web.config file) and can’t be overridden at any folder level web.config files. By default, AspNetCompatibilityRequirementMode is : Allowed.
9. Is overloading possible in WCF? If yes then how?
Answer : Yes, by using [OperationContract(Name="OverloadedName")] But, still outer world will get them with unique and different name. Overloading is a technique to write manageable/maintainable code. But in case of WCF service, uniqueness is required for generating WSDL, and that can be done either by using unique method name or unique OperationContract's name attribute value. Interfaces plays an important role and provides much flexibility for this. We can write many implementations of an interface, and it gives more flexibility plus concise. So why to think on overloading for WCF service methods?
New Questions added on 05-April-2015:
10. What is MAC in WCF ?
11. How Event Logging is done in WCF ?
No comments:
Post a Comment