开发者

Using a WCF Data Access & Business Logic Layer

开发者 https://www.devze.com 2023-03-29 20:45 出处:网络
We are starting development of an web application which would later be ported to mobile as well. So I was thinking to encapsulate Data Access and Business Logic inside an WCF Layer. This would make it

We are starting development of an web application which would later be ported to mobile as well. So I was thinking to encapsulate Data Access and Business Logic inside an WCF Layer. This would make it easier to sync and manage it later.

The data access layer would consist of an Repository Layer above an ORM (Codesmith - PLINQO). The application is multi-tenant (SaaS) and uses shared database approach.

WCF and Web App will reside on the same server and WCF Binding would be NamedPipes.

Is the above approach correct or there might be some peformance hit on using a WCF Layer? Any advice or readable material for better structuring t开发者_开发知识库he application is also welcomed.


It depends on rest of your requirements. Named pipe communication has always performance hit. You can just make some test to call operation directly multiple times and to call operation through the named pipe to get some numbers to compare. There are alternatives to named pipes to host the service in process instead of another process - null channel or local channel but even those solutions will be still slower then direct call.

You are planning your architecture for the future so you should now define what the future means as well. How will mobile devices consume your services? Will it be SOAP or REST? Those are two different approaches and you can find that services you prepared for your web application (SOAP) are not very useful for mobile devices (where you can want to use REST because it is better supported and more popular).

If you don't know what the future means it makes no sense to make any preparation because you will most probably prepare for something which will not happen = your current effort will be wasted and you will have to change your application later anyway.

Using same services for your application (= internal service) and for mobile devices (= external service) can have different security requirements. For example your web application can already handle authorization but for mobile devices the authorization will have to be performed on services. Authorization is global for a service so for your web application you will do authorization twice.

In my opinion you should start with business logic as a library which will be consumed directly by your web application. Once you need to add services for mobile devices create just service wrappers around your business logic. Adding WCF layer for your web application make sense if you want to divide front end and back end on different servers or if you want to scale business logic and frond end separately but when they run on the same server it will only introduce performance decrease and it will probably not make your development for mobile devices easier. Even in scenario where you would have business logic deployed separately you should think carefully if you want to expose business services directly to mobile devices. It is not uncommon to expose another layer of public services calling internal business services - that is usually used in projects with strict security where business services must sit in different network perimeter.

0

精彩评论

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