Krister | 6 Aug 10:55
Picon
Favicon

WCF: Data contract on domain objects or seperate contract objects?

I have a question about best pratices about where to set the 
[DataContract] and [DataMember] attributes when using WCF. Today I have 
set the attributes on the domain objects but is it better to have 
contract objects instead?

If so, where should I have the contract objects stored? In the WCF 
layer or in the Business logic layer?

One other question I have is if there is some kind of good way to mapp 
domain objects to contract objects?

Best regards
Lukas

------------------------------------

John Teague | 6 Aug 21:44
Picon

Re: WCF: Data contract on domain objects or seperate contract objects?

I consider any endpoint on a WCF contract as a Context Boundary and use the WCF Impl as the Anti-Corruption Layer.  Therefore I use DTOs as return values and parameters in WCF contracts.

As to the location of the DTOs will depend on whether or not you plan on sharing the data types or not.  If so I would have them in the WCF project.

If you're exposing them in a WSDL, then you could put them in the domain layer.

I guess it depends on where you want to do the dto conversion as well.

John


__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Krister | 9 Aug 17:10
Picon
Favicon

Re: WCF: Data contract on domain objects or seperate contract objects?

Hello John
Thank you for your short and good answer!

Do you have any thoughts about the mapping? Is there some kind of 
mapping pattern that you recommend between DTO:s and domain objects?

Regards
Lukas

--- In domaindrivendesign <at> yahoogroups.com, "John Teague" 
<jcteague@...> wrote:
>
> I consider any endpoint on a WCF contract as a Context Boundary and 
use the
> WCF Impl as the Anti-Corruption Layer.  Therefore I use DTOs as 
return
> values and parameters in WCF contracts.
> 
> As to the location of the DTOs will depend on whether or not you 
plan on
> sharing the data types or not.  If so I would have them in the WCF 
project.
> 
> If you're exposing them in a WSDL, then you could put them in the 
domain
> layer.
> 
> I guess it depends on where you want to do the dto conversion as 
well.
> 
> John
>

------------------------------------


Gmane