Jon Archway
Jon Archway

Reputation: 4892

WCF IsFault and FaultException

OK, I am getting myself a little confused here. I have a WCF service (service A) that calls another WCF service (service B). When I throw an exception on Service B e.g. throw new Exception("test") then service A does not get an exception, instead the IsFault is set to true on the response message e.g.

responseMessage = forwardingChannel.Process(message)
if (responseMessage.IsFault) {
    // Yes, there is a fault
}

I expected that I could put a try-catch around the Process method and receive the exception. Could someone explain to me what is going on here please?

Thanks

Upvotes: 0

Views: 986

Answers (1)

John Saunders
John Saunders

Reputation: 161783

If Service A were a Java service, would you expect to get a .NET exception back from calling Service B?

By default, an unhandled exception in a WCF Service will be returned as fault. If the service is using SOAP, that will be returned as a SOAP Fault. In a normal WCF client, that will get translated into a FaultException.

Upvotes: 1

Related Questions