If you are new to WCF Data Services then you may encounter some initial frustration when things don’t go according to plan.

One of the most common errors and one that I repeatedly fall in to results in a “The server encountered an error processing the request. See server logs for more details.” error.

Completely unhelpful and even the server logs don’t show much of value.

If you are getting this error then read on for the most common cause I seem to hit and the indispensable tools for debugging.



Ok so the first thing you need to arm yourself with is Fiddler which you can find over here.

Using Fiddler you can monitor Web Requests as they hit your server and garner all sorts of useful information, including the actual error that is occurring on the Web Server, which may not be visible to you. When using WCF Data Services it will probably be your actual application making the calls to the services.



If you don’t already use Firefox as a Web Developer you might want to start doing so. As much as I like the other browsers, Firefox is definitely the best from a developer perspective.

Once you have Firefox installed you can get Firebug as an Add-on from the Tools|Add-Ons menu.

Using Firebug you can step through your javascript which is extremely useful when debugging calls to WCF Data Services.

Firebug - Script Debugging

As you can see from the screenshot above you can step through your code and examine variables in the Watch Window just as you would in Visual Studio.

Common Problem

As I mentioned at the start of this post I find myself coming across a common error when debugging WCF Data Services that might prove extremely frustrating to anyone new to the game.

The Error is shown in both Firebug and Fiddler above and as you can probably see is not extremely helpful.

Ok so what are the common causes:

  1. A missing SetEntitySetAccessRule
  2. A missing pluralisation on the SetEntitySetAccessRule
  3. A missing SetServiceOperationAccessRule
  4. A combination of the above.

So lets look at an example:

[WebGet] public List GetTimeZones() { List timeZones = new List(); VPFreeEngine.VPSurvey surveyEngine = new VPFreeEngine.VPSurvey(Properties.Settings.Default.DbConn, 1); foreach (VPFreeEngine.BusinessObjects.SurveyTimeZone item in surveyEngine.GetLookupTimeZone()) { AbstractTimeZone newTimeZone = new AbstractTimeZone(); newTimeZone.TimeZoneId = (int)item.SurveyTimeZoneID; newTimeZone.TimeZoneDisplay = item.TimeZoneDisplayName; timeZones.Add(newTimeZone); } return timeZones; }

The sample code above uses a third party API and then converts the data in to what I refer to as an Abstract object which is purely to enable transport of the data via WCF Data Services. Not ideal perhaps but it gets the job done.

So having just got back from holiday I started to make some updates to the site I am working on and of course my head was still in holiday mode so I forgot the basics again.

Having written my method above, added the [WebGet] attribute and also the SetServiceOperationAccessRule in my InitializeService method I assumed I was ready to go.

config.SetServiceOperationAccessRule("GetTimeZones", ServiceOperationRights.All);

And that’s when I got the ‘500 – Internal Server Error” or “The server encountered an error processing the request” error.

After a bit of fiddling about I realised I had forgotten to add the SetEntitySetAccessRule line of code so I copied my entity name and created the entry, compiled and ran the code again but still no luck.

config.SetEntitySetAccessRule("AbstractTimeZone", EntitySetRights.AllRead);

I pondered this again for a moment and then realised that the EntityName is singular and not plural which is what the SetEntitySetAccessRule expects.

config.SetEntitySetAccessRule("AbstractTimeZones", EntitySetRights.AllRead);

As soon as I changed this, all was well.

So just to recap, if you are having trouble with your WCF Data Services and getting the general errors listed in this post be sure to check for these 3 things:

  1. A missing SetEntitySetAccessRule
  2. A missing pluralisation on the SetEntitySetAccessRule
  3. A missing SetServiceOperationAccessRule