设计具有表示层和基于 Web 服务的 API 的系统 [英] Designing a system with a presentation layer and a web service-based API

查看:21
本文介绍了设计具有表示层和基于 Web 服务的 API 的系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在设计一个系统,该系统在表示层和公开的 API 层具有基本相同的功能.我的问题是使用什么技术/策略才能在考虑性能的情况下从代码中获得最大的重用?

We are designing a system that has functionality that is essentially the same at the presentation layer and the exposed API layer. My question is what technique / strategy to use so we can get the most reuse out of our code with performance in mind?

这是一个简化的例子:

用户可以通过网络表单添加客户.这将触发 Customer.Create() 方法.

A user can add a Customer via a web form. This will fire the Customer.Create() method.

API 使用者/用户可以通过 SOAP/HTTP-POST 向将调用 Customer.Create() 方法的网络服务添加客户.

An API consumer / user can add a Customer via a SOAP / HTTP-POST to a web service which will call the Customer.Create() method.

想象一下这些层:

PRESENTATION
|
|
WEB SERVICE API (Customer.Create() is available here
|
|
FACADE Business Object Interface - Customer.Create() signature is here
|
|
BUSINESS Business object - Customer.Create method() is fleshed out here
|
|
DATA ACCESS - Writes data

表示层 SOAP 调用 Create() Web 方法,该方法调用 Facade 的 Create() 方法,该方法调用通过数据访问层连接的业务对象的 Create() 方法.

The presentation layer SOAP calls the Create() web method, which calls the facade's Create() method which calls the business object's Create() method which wires via the data access layer.

问题:

在我们的表示层中使用 API 的 Web 服务时是否存在性能问题,或者是否存在将表示层直接连接到外观的替代方法?如果是,要使用什么技术(WCF、远程处理、Web 服务等)?

Is there a concern about performance in using the API's web services in our presentation layer, or are there alternatives to connect the presentation layer directly to the facade? If so, what technology to use (WCF, Remoting, Web Services, etc)?

如果您需要更多说明,请告诉我.我无法确定在表示层中使用您的 API 是否很常见,或者您是否出于性能原因绕过它".

Please let me know if you need any more clarification. I am having trouble finding out if it is common to consume your API in a presentation layer, or do you "go around it" for performance reasons.

还有其他我可能看不到的问题吗?

Any other concerns that I may not be seeing?

谢谢!

推荐答案

看看这个问题和答案(我的一个):

Have a look at this question and answers given (one mine):

WCF 和 n 层架构和序列化性能

我认为你的层如果都是逻辑就可以了,尽管我个人不会使用 Facade,而是使用 ORM 来连接到数据库.

I think your tiers are fine if they are all logical although I would personally not use Facade and instead I would use an ORM for connecting to database.

就技术而言,WCF 和 ASP.NET MVC 比现在陈旧且效率低下的 Web 服务要好得多.远程处理已被 WCF 取代,现在不应使用.

Regarding technologies, WCF and ASP.NET MVC are so much better choices over web services which is old and ineffecient now. Remoting was superceded by WCF and should never be used now.

这篇关于设计具有表示层和基于 Web 服务的 API 的系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆