.netjsonwcfrestierrorhandler

Accessing message in WCF service when I get serializing exception


In WCF service I have custom IErrorHandler. Works great and I fixed lot's of stuff by logging errors. Last error I'm getting is serialization exception:

Unexpected end of file. Following elements are not closed: Source, item, root.

There was an error deserializing the object of type System.Collections.Generic.List`1[[My.Web.Services.Dto.Log, My.Web.Services.Dto, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. Unexpected end of file. Following elements are not clo

That tells me that message didn't come in properly from a client. Is there any way I can see what message it was? Can I access HTTP post paramteres from inside IErrorHandler ?


Solution

  • Create a WCF MessageInspector , (IDispatchMessageInspector) it will let you access the message before it is deserialized, see the AfterReceiveRequest method in the linked example. Ian Picknell has a more lengthy post with more details