开发者

How to reuse service layer in WCF and standard ASP.NET scenarios

开发者 https://www.devze.com 2023-01-16 04:10 出处:网络
I\'d like to be able to create standard POCO service that I can use in two distinct workflows: in-process i.e. consumed by my ASP.NET webforms application

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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消