5

我正在考虑通过慢速卫星连接创建数据查询 WCF 服务,我真的很喜欢 WCF 数据服务。我看到的问题是 HTTP 是一种非常冗长的格式,由于我所做的一切都是内部和 .NET,是否可以使用 NetTcpBinding 来减少一些开销?

这甚至可能吗?可取的?

4

2 回答 2

4

While researching this on my own, i ran across the MSDN article on Self-Hosted WCF Data Services. This article notes that you can host the service with DataServiceHost which still requires HTTP (it's derived from WebServiceHost).

But you can also roll your own host using IDataServiceHost. Here's an excerpt from the MSDN article:

For cases where the WCF host implementation is too restrictive, you can also define a custom host for a data service. Any class that implements IDataServiceHost interface can be used as the network host for a data service. A custom host must implement the IDataServiceHost interface and be able to handle the following basic responsibilities of the data service host:

  • Provide the data service with the service root path.
  • Process request and response headers information to the appropriate IDataServiceHost member implementation.
  • Handle exceptions raised by the data service.
  • Validate parameters in the query string.

The article seems to suggest that MS has properly segrated data-service responsibilities from network interface responsibilities. If that's so, then I should be able to write a NetTcpDataServiceHost. Has anyone ever written a IDataServerHost? Any suggestions?

于 2010-09-03T21:03:56.993 回答
3

不,WCF 数据服务建立在 REST 之上,而 REST 本身非常紧密且完全基于 HTTP 动词,如 GET、PUT、POST 等 - 您不能通过 NetTcp 运行它们,因为它们本质上与 HTTP 协议相关联堆。

也许还有其他选择可以减少传输的数据?调整你的对象 - 如果可以的话,修剪脂肪 - 同时检索一次检索的行数,以及传输的属性/数据字段的数量。这可能是你最有希望的方法。

于 2010-09-03T20:50:54.590 回答