views:

43

answers:

1

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?

A: 

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.

Ladislav Mrnka
Thanks, I have also considered the implementation of WCF proxy class. My client-proxy class inhereted from ClientBase~1. This class uses RealProxy that performs to call HandleResponseMessage method. This method throws exeption when I use fake message. So my question: how have you wrap WCF proxy?
Veleslav