View Single Post
  #14 (permalink)  
Old 08-07-2007, 01:34 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Default Re: Windows Communication Foundation

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?
__________________
H2O

Without us, no one can survive..
Reply With Quote