I need to implement custom caching of client proxy of wcf service. I've implemented the IOperationBehavior interface. On server-side we can set OperationDescription.Invoke property in ApplyDispatchBehavior method and implement IOperationInvoker interface to control operation execution. On client-side we can't do it.
In client-side we can use the IClientMessageInspector, IParameterInspector, IClientMessageFormatter interfaces to control开发者_运维问答 message flow. The main problem is that I have to store in cache only the service answer without information about message format. When I restore values from cache I should create message again like in case of service response. I cannot break following internal message processing. So on that moment I lose necessary information about message such as encoding, content-type(json, xml) in case of RESTful services. Final result - WCF cannot process such message. I want to disable message processing if cached value exists. How I can do it?
I would choose absolutely different approach. Instead of injecting some functionality into WCF pipeline I would define interface for WCF proxy wrap WCF proxy into custom class (Caching proxy) and implement interface on this wrapper class. Than call to WCF will be done only if caching proxy does not contain required data.
精彩评论