views:

46

answers:

1

I'd like to be able to create standard POCO service that I can use in two distinct workflows:

  1. in-process i.e. consumed by my ASP.NET webforms application
  2. remotely via an exposed WCF endpoint to be consumed by other applications

Is there a way to re-use the same service and its return data types in both scenarios above? Ideally, my core service and data types would not have to be decorated with WCF specific attributes and I could add these attributes in some kind of WCF facade layer.

Thanks!

+1  A: 

Since .NET 3.5 you don't need to decorate your data objects with WCF related attributes (DataContract, DataMember). If you don't use them default serialization will be used - all properties with public getter and setter will be serialized (also class has to have public parameterless constructor).

Sharing "service" layer works exatly as you have described. You create business service layer which exposes functionality. This functionality is consumed in-process by your ASP.NET application. Than you create wrapper layer which is marked with WCF related attributes and exposed as WCF service. Your WCF layer can be handled as facade and compound several business calls to single web service call.

Ladislav Mrnka