Search code examples
wcffault

WCF client returns error "The remote server returned an error: NotFound."


I am migrating a WPF application to Silverlight. My WPF application accesses a Web Service using BackgroundWorker. If there is any error while accessing the web service I get an extensive error message in my callback, for example

There was no endpoint listening at http://localhost:8080/services/registration
that could accept the message. This is often caused by an incorrect address or
SOAP action. See InnerException, if present, for more details.

In my Silverlight application, I am accessing the same web service asynchronously and now my error messages are not very useful, for example:

 The remote server returned an error: NotFound.

The web service has not changed - I can see the faults coming from the server on Fiddler. So the question is how can I get more detailed error messages on the Silverlight client.

My callback in Silverlight application looks like this (I am accessing the error message from e.Error.Message):

private void AuthenticateUserCallback(object sender, AuthenticateUserCompletedEventArgs e)
{
    if (e.Error != null)
    {
        this.StatusMessage = e.Error.Message;
    }

    ...
}

Solution

  • This is limitation with Browser stack due to which SL cannot access the complete exception message. Look at MSDN article here The approach is to wrap exception into meaningful faults (which means client will always get HTTP OK 200) and perform custom exception handling on the client side.