简体   繁体   English

WCF服务,WCF数据服务,Web Api,SignalR? 使用什么?

[英]WCF service, WCF Data Service, Web Api, SignalR? What to use?

I know there might not be one simple answer for this, but i was hoping if somebody can point me in the right direction... 我知道可能没有一个简单的答案,但是我希望有人能指出我正确的方向...

We have an ASP.NET webforms application with its own MS SQL database at our company's office, but now we want to show some data in this application from another MS SQL database, which is not at our company's office. 我们在公司办公室有一个带有自己的MS SQL数据库的ASP.NET Webforms应用程序,但现在我们希望从不在公司办公室的另一个MS SQL数据库中显示该应用程序中的一些数据。 We need to request the data server-side, so not directly from the webbrowser. 我们需要在服务器端请求数据,而不是直接从Web浏览器请求。

We don't want to use a direct sql connection to this remote database, but prefer to create a service which can do some business logic before returning the data. 我们不想使用到该远程数据库的直接sql连接,而是希望创建一个可以在返回数据之前执行一些业务逻辑的服务。 Business logic is very simple (such as retrieving some values end returning the average). 业务逻辑非常简单(例如检索某些值最终返回平均值)。

A couple years ago we did almost the same by writing a WCF service with a BasicHTTPBinding. 几年前,通过编写带有BasicHTTPBinding的WCF服务,我们几乎做了同样的事情。

But now, after doing a couple hours of research, i'm a little bit confused about whats the best approach? 但是现在,经过几个小时的研究,我对什么是最佳方法感到有些困惑。

  • WCF Service WCF服务
  • WCF Data Services WCF数据服务
  • ASP.NET Web API ASP.NET Web API
  • SignalR 信号R

Maybe somebody can give me some good tips? 也许有人可以给我一些好提示?

You're looking for machine-to-machine communications, in which case WCF still beats the rest in my experience. 您正在寻找机器对机器的通信,在这种情况下,WCF在我的经验中仍然胜过其他人。

You simply define data contracts for the entities you wish to exchange and happily code your logic in the WCF service. 您只需为要交换的实体定义数据协定,并在WCF服务中愉快地编写逻辑代码。 Then you generate a client, apply the proper binding (given machine-to-machine, net.tcp looks like an efficient candidate) and off they talk. 然后,您生成一个客户端,应用适当的绑定(给定机器对机器,net.tcp看起来像是一个有效的候选者),然后他们开始交谈。

As for the rest: WCF Data Services - works nice if your data model matches the database model, which hardly ever is the case. 至于其余的内容:WCF数据服务-如果您的数据模型与数据库模型匹配,则效果很好,几乎没有这种情况。 When you need custom operations or wish to return different entities than database entities, Data Services are more cumbersome than plain WCF. 当您需要自定义操作或希望返回与数据库实体不同的实体时,数据服务比普通的WCF更为麻烦。

ASP.NET Web API and SignalR are mainly meant to consume from a browser. ASP.NET Web API和SignalR主要用于从浏览器中使用。 It's harder to generate a strongly-typed client for those. 很难为这些客户生成强类型的客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM