views:

107

answers:

1

I have a WCF service (.NET 4) hosted in IIS. My service contract has one method with:

[FaultContract(typeof(string))]

My service implementation for that method validates input parameters and may throw an exception like this:

if (string.IsNullOrWhiteSpace(siteName)) { throw new FaultException("siteName is required."); }

The consumer program of this service is a .NET 2 console application. In this app I generated the webservice proxy by right clicking "References" and "Add web reference".

When I try to call the service method from the client app, by sending an invalid siteName, I get back a 503 Service Unavailable exception, instead of a FaultException with the custom error message.

How can I make the FaultException, with the custom error message, propagate to the client program?

UPDATE:

The exception I get in the client application is this:

System.ServiceModel.ServerTooBusyException: The HTTP service located at http://www.example.com/services/myservice.svc is too busy. ---> System.Net.Web Exception: The remote server returned an error: (503) Server Unavailable.
at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha nnelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace ---

A: 

The problem was being caused by a custom HTTP module in our web project. So it was not exactly a WCF problem, but a problem specific to our solution. Thanks!

sunda2010