Abhijeet
Abhijeet

Reputation: 13886

WCF extensibility point: To obtain fake response from the disk rather than service?

My Asp.Net web applications makes extensive calls to WCF services. For debugging UI issues, I use to deserialize earlier saved WCF responses. This is controlled by a config key.

However by manual deserialization, I miss-out some of the deserialization issues which could arise out of wrong entries in ServiceModel of Web.config file.

Thus, using WCF extensibility points I wish -

  1. Read xml response from the disk.
  2. Let WCF framework desrialize the xml for me.

Which extensiblity point can be helpful to achieve this ?

Edit:

To be precise, I am trying to play around with these values offline (without hitting actual service), to find the optimum value for our scenario -

<binding name="voucherServiceBinding" closeTimeout="00:01:00" 
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
          allowCookies="false"> 
         <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
             maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
</binding>

Upvotes: 0

Views: 187

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87258

Bypassing the network request is certainly possible in WCF, but unfortunately it's not easy to implement. What you need is a protocol channel (i.e., going into the WCF channel layer), which will intercept the request and respond instead of sending it down the channel stack (where it would reach the transport channel).

The post at http://blogs.msdn.com/b/carlosfigueira/archive/2011/07/12/wcf-extensibility-channels.aspx has an example of such a channel which can be used to bypass server operations. You'll need to read the XML you want from the disk and create a WCF System.ServiceModel.Channels.Message object based on it. Good luck.

Upvotes: 1

Related Questions