I have a solution structure where the contracts (Data/Service etc) are in a different project from the business entities and I am using Automapper to map between from a third Service implementation project.
WCFProject.Service.BusinessLayer
WCFProject.Service.Contracts
WCFProject.Service.Impl
My ServiceImpl has reference to both these other projects and the automapping from DataContract to BusinessEntity is done here and then the correct method is called on the BusinessEntity object
Now, I want to add a few FaultContracts
and then use them in my business logic to throw the right exceptions. But if I add them to the Contracts project (which is ideal since I want to keep all my contracts together), then I need a reference from BusinessLayer to Contracts to use them in BusinessLayer. I wanted to keep these independent if possible and just deal with DTOs between these two layers. Is that a valid agrument from my side that I want to keep the two projects independent? Do you map exceptions as well? Or is there a better way to deal with this.
Your business layer should have not knowlage of the above layers. So it does not know anything about that you have a wcf layer on top. Throwing fault is something from your wcf layer, catch your exception there and dicide what you want to do. A business exception can be mapped to a wcf fault, but if you have a connection of nullpointer exception you just want to give a general fault that something is wrong.
A sample of handing/mapping errors in a service behavoir can be found here: WCF-Exception-Handling
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With