Как мне обработать ошибки десериализации WCF SOAP в HTTP Reponse? - PullRequest
1 голос
/ 24 января 2012

Как скрыть следующую информацию об ошибке и показать пользовательское сообщение в WCF?Эта ошибка возникает, когда мы вводим неверный параметр в http запрос

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 Ответ

1 голос
/ 24 января 2012

Вам понадобится специальный десериализатор WCF, который может перехватывать ошибки и создавать собственные сообщения об ошибках. Посмотрите здесь: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/dcd48a7f-4494-455f-8504-cbdc372badcf/

...