c# - WCF - 我什么时候应该使用 netTcpBinding

标签 c# wcf

我通常在我的服务中使用 HTTP 绑定(bind)。
我读到 net.tcp 绑定(bind)工作得更快,但是我不太确定我应该什么时候使用它?
什么是最佳实践, 有什么缺点吗?

谢谢

最佳答案

NetTcpBinding 的 MSDN 页面说得最好

The default configuration for the NetTcpBinding is faster than the configuration provided by the WSHttpBinding, but it is intended only for WCF-to-WCF communication.

因此,当您拥有 .NET WCF 客户端和 .NET WCF 服务器时,NetTcpBinding 非常适合使用,但是如果您需要支持不是用 .NET WCF 编写的客户端(例如,您正在发布公共(public)服务并且您不知道客户端将使用哪种语言编写),那么您需要改用 HttpBinding。

This page对每种类型的绑定(bind)以及何时使用它们有一个很好的快速总结。

  • BasicHttpBinding - A binding that is suitable for communicating with WS-Basic Profile conformant Web services, for example, ASP.NET Web services (ASMX)-based services. This binding uses HTTP as the transport and text/XML as the default message encoding.
  • WSHttpBinding - A secure and interoperable binding that is suitable for non-duplex service contracts.
  • WS2007HttpBinding - A secure and interoperable binding that provides support for the correct versions of the Security, ReliableSession, and TransactionFlow binding elements.
  • WSDualHttpBinding - A secure and interoperable binding that is suitable for duplex service contracts or communication through SOAP intermediaries.
  • WSFederationHttpBinding - A secure and interoperable binding that supports the WS-Federation protocol, enabling organizations that are in a federation to efficiently authenticate and authorize users.
  • WS2007FederationHttpBinding - A secure and interoperable binding that derives from WS2007HttpBinding and supports federated security.
  • NetTcpBinding - A secure and optimized binding suitable for cross-machine communication between WCF applications.
  • NetNamedPipeBinding - A secure, reliable, optimized binding that is suitable for on-machine communication between WCF applications.
  • NetMsmqBinding - A queued binding that is suitable for cross-machine communication between WCF applications.
  • NetPeerTcpBinding - A binding that enables secure, multi-machine communication.
  • WebHttpBinding - A binding used to configure endpoints for WCF Web services that are exposed through HTTP requests instead of SOAP messages.
  • MsmqIntegrationBinding - A binding that is suitable for cross-machine communication between a WCF application and existing Message Queuing (also known as MSMQ) applications.

关于c# - WCF - 我什么时候应该使用 netTcpBinding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19212159/

相关文章:

c# - 如果使用 XML 前缀,则 XSLT 转换只会导致页面标题 h1::Documents 以 html 格式打印

c# - 在 DropDownList 中显示多个值并以编程方式访问这些值

c# - WCF、 channel 工厂和异常

c# - WCF:配置角色以访问数据库资源

c# - Web 应用程序中用于周期性任务的子系统

c# - WCF 使用凭据和 IIS 以编程方式启用 TLS

c# - 包含全窗口覆盖的用户控件

c# - 在 Active Directory 上枚举用户所需的安全权限是什么

c# - 如何使用Microsoft Bot框架通过Facebook Messenger(C#)向用户发送音频

c# - 尝试上传大文件大小时出现异常