I have a requirement for a WCF service I've created to be able to go into "read only" mode. While in this state it will not service requests for calls that would make changes to the database (like creating an order) but will only service read-only requests (like authenticate user). If it receives a request that it will not service, it needs to pass back a friendly message and code (e.g. CODE: 100, DESCRIPTION: "Service is in read only mode and cannot service this request").
I have close to 100 different calls and would like to implement a solution that can be made in one place (like an IDispatchMessageInspector) but I don't see a way to provide a response to any intercepted WCF messages. I have a standard response type that I send back on ALL requests and would like to send that back in these situations as well. The type is named ServiceResponse and has a messages collection. which is a class of Codes and Descriptions.
public class ServiceResponse
{
public List<Message> Messages {get; set;}
}
public class Message
{
public string Code {get; set;}
public string Description {get; set;}
}
Can someone provide me with a direction on how to do this? I have exhausted all of my searching options.
Even if there is just a way in WCF to hand create the SOAP I'm sending back, that's fine as long as I don't have to handle the read-only check / response in every single service call.
Thanks!