How do I handle WCF SOAP deserialization errors in HTTP Reponse?

3.1k views Asked by At

How do I hide the following error information and show custom message in WCF? This error occur when we inject invalid parameter in http request

HTTP/1.0 500 Internal Server Error
Cache-Control: private
Content-Length: 494
Content-Type: text/xml; charset=utf-8
Date: Mon, 23 Jan 2012 22:34:36 GMT
X-Cache: MISS from test.int.testgroup.com
Via: 1.0 test.int.testgroup.com:80 (squid/2.6.STABLE22)
Proxy-Connection: close

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode><faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'GetData'. Character reference not valid. Line 1, position 121.</faultstring></s:Fault></s:Body></s:Envelope>
1

There are 1 answers

0
lockstock On

You will need a custom WCF deserializer that can catch the errors and produce custom error messages. Have a look here: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/dcd48a7f-4494-455f-8504-cbdc372badcf/