WCF Interview Questions:
- How do you enable logging and auditing in WCF?
- What WCF service security events should be logged?
- How do you Implement log throttling in WCF?
- How do you protect your log files?
- How do you stop your service if there has been an auditing failure?
- How do you implement health monitoring features in WCF?
1. How do you enable logging and auditing in WCF?
There are three ways you can use to audit and log operations in your WCF service:
- Use WCF auditing to audit security events such as authentication and authorization failures.
- Use WCF message logging to log malformed SOAP messages or to trace incoming messages.
- Use ASP.NET health monitoring to provide custom logging
Enable WCF Auditing in your config file with a serviceSecurityAudit service behavior as follows:
Enable message logging in your config file by creating a ServiceModelMessageLoggingListener andSystem.ServiceModel.MessageLogging source, and then add MessageLogging under the diagnostics node as follows:
Reference books, you may like:Programming WCF Services: Design and Build Maintainable Service-Oriented Systems
WCF Multi-Layer Services Development with Entity Framework, 4th Edition
Learning WCF: A Hands-on Guide
2. What WCF service security events should be logged?
- Use WCF auditing to log authentication successes and failures.
- Use WCF auditing to log authorization successes and failures.
- Use WCF message logging to log malformed Simple Object Access Protocol (SOAP) messages.
- Use ASP.NET health monitoring in conjunction with your input and data validation routines to log malformed parameters and schema in incoming WCF messages.
3. How do you implement log throttling in WCF?
you can specify the maximum number of messages to log as well as the maximum size of the messages to be logged.
These attributes can be found in the <messagelogging> element:
- maxMessagesToLog. Allows you to limit the size of the log file, by reducing the total number of messages in the log. This setting can be used to reduce the chances of a denial of service (DoS) attack on your log but can be used by an attacker to fill up the log and conceal their intrusion.
- maxSizeOfMessagesToLog. Allows you to limit the size of the log file, by restricting very large messages from being logged. This setting can be used to reduce the chances of a DoS attack on your log but could potentially be used by an attacker to conceal their intrusion by ensuring that certain messages are not logged
4. How do you protect your log files?
Protect your log files using Microsoft Windows access control lists (ACLs) with restricted access.
If you log events to Microsoft SQL Server or to a custom event sink, use appropriate access controls to limit access to the event data.
For example, grant write access to the account or accounts used by your application, grant full control to administrators, and grant read-only access to operator
5. How do you stop your service if there has been an auditing failure?
you can set the SuppressAuditFailure element to false to throw an exception when there has been an auditing failure. By default, this property is set to true, which means your service can continue running even after auditing has failed and no additional events are being logged.
6. How do you implement health monitoring features in WCF?
To use the health monitoring feature with WCF, configure your WCF service by performing the following steps:
- Create a custom health monitoring event.
- Configure your WCF service for health monitoring.
- Instrument an application to raise a custom event.
© 2015, admin. All rights reserved.