Ensuring WCF Correctly Reports Errors

This is another one of my note to my future self posts, that might be useful to somebody else, so skip past if you don’t know what WCF is…

Anyway, if you’re still here, I’ve spent the past day or so trying to track down a problem in some WCF code. Essentially the problem has been that whilst I have been out of the office over the last week, we’ve had a change propagate through to our development server which has caused problems with some of our existing services, specifically some code where one service needs to make a call to another service running on the same machine to finish it’s work. To do this it needs to pass through the Kerberos ticket that the initial service has received, and whilst up to now it has been quite happily doing this, now it has stopped and instead is getting the credentials for the underlying windows service passed.

The problem was made a lot harder to diagnose by a little WCF gotcha whereby the error that is generated is overwritten when the calling code tries to dispose of the service object. Damien McGivern has an excellent post describing the problem and giving a solution, however it didn’t quite meet our needs, as we sometimes need to specify an endpoint when creating the proxy object.

To get around the problem, I adapted Damien’s code slightly creating an extension method taking an object of type TService rather than creating the object within the method, so the method can be used as follows:

new RelationshipServiceClient().UsingService(service => ... );

Whilst it doesn’t actually solve the mystery of why our server started mishandling WCF calls, it did at least give us a bit more clue!

Subscribe / Share

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

One Comments Post a Comment
  1. Kirk says:

    Can you provide the code for your extension method for this?

Leave a Reply




Asides

Flickr Pictures

The Advisor Reads the List DSCF0319.JPG New Year Dip View from the Top of Setting Up Another Group Shot Looking Back at the Swing Bridge Rev Richard Sings Lucy Finance Christmas Lunch Dartmouth Street View Paul Font Talking in the Garden View Down the Lane Lucy and Beth Looking Serious Tomb in the Snow School Christmas Party West Herts 16mm Meeting Dad, Simon and Lucy Sunlight through Stained Glass At the Reception Insect on the Windscreen 2 Meg gets a Better View

Lifestream