Let me just code what I mean.
This would be the service consuming code:
Code:
// ...
IProductsService productsService = ServiceContainer.GetService();
try
{
Product[] productsService.GetProducts(category);
}
catch (InvalidProductCategoryException bex)
{
// ...
}
catch (ProductSystemException exe)
{
// ...
}
// ... This would be a service adapter for WCF:
Code:
public class WcfProductsServiceAdapter : IProductsService
{
public Product[] GetProducts(string category)
{
GetProductsRequestMessage request Translators.Get(category);
Adapters.BeforeSendMessage(request);
GetProductsResponseMessage response;
using (ProductsServiceClient client new ProductsServiceClient())
{
try
{
response = client.GetProducts(request);
}
catch(Exception ex)
{
throw new ProductSystemException(ex.Message, ex);
}
}
Adapters.AfterReceiveMessage(response); // throws business exceptions
// based on error information
// on the respone message.
return Translators.GetList<Product>(response);
}
} Using this pattern, you can have your code receiving business exceptions even if the comminication code is to using exceptions for business errors.
Using this pattern, you can implement your service adapter using WCF with MessageVersion.None, ASMX, COM+, database, XML file, etc.
I hope I understood correctly the question: WCF, FaultException and business errors, right?