0

I have a .net 4.5 client with a standard Service Reference to a remote Windows WCF service.

Sometimes, when things go horribly wrong on the server, it will actually return HTML instead of the strongly-typed response my Service client expects. The server will completely violate the interface/contract our software adheres to.

The server does not throw a FaultException. I do not get a CommunicationException, or anything else "normal". I have catch{} blocks for several exceptional things that might happen in the channel, but I am at a loss to determine how to explicitly deal with this problem of getting an HTML string instead of valid bits.

Can anyone say how I can smartly explicitly trap this kind of server activity? It is rare but happened enough that it wrecks my WCF client behavior

Thanks.

Snowy
  • 5,942
  • 19
  • 65
  • 119
  • When you say "The server does it throw a FaultException or anything else "normal", it sends a string of markup." you meant that the server doesn't send a FaultException right? Otherwise asking this question would make no sense I guess. – Selcuk S. May 21 '13 at 13:14
  • Remote server does not send a FaultException. My client does not get an actual "error" until my proxy client deserializes the message from the server, and then things go bad because the message is human readable HTML markup "an error has occurred. please try again later". – Snowy May 21 '13 at 13:29
  • 1
    If the response doesn't match your service contract you must be getting deserialization exception. Why can't you catch and handle it then? – Maksym Strukov May 21 '13 at 14:30
  • I did not see a deserialization exception in the logged data. I will double check that. Thanks. – Snowy May 22 '13 at 13:16

1 Answers1

0

If you host your wcf service in IIS and have in your service behavior a serviceDebug section with the property IncludeExceptionDetailInFaults. You will experience this problem if your service throws an exception that derives from System.Exception in stead of an FaultException.

You write that you host your wcf service in a windows server. So my response might not be valid, but you should check the IncludeExceptionDetailInFaults setting.

Frode
  • 336
  • 4
  • 15