gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 21:39:45 24 4
gpt4 key购买 nike

我通常在我的服务中使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com