在WCF中,有几种不同类型的基于HTTP的绑定:
- BasicHttpBinding(基本HTTP绑定)
- WsHttpBinding(WS-HTTP绑定)
- WebHttpBinding(Web HTTP绑定)
这三者之间有哪些区别?
特别是在功能、性能和兼容性方面有何不同?
这三者之间有哪些区别?
特别是在功能、性能和兼容性方面有何不同?
这里你在比较不同的东西:
webHttpBinding 是REST风格的绑定,基本上您只需访问一个URL并从Web服务获得大量的XML或JSON数据即可
basicHttpBinding 和 wsHttpBinding 是两种基于SOAP的绑定,与REST非常不同。 SOAP的优点是具有WSDL和XSD来详细描述服务、其方法和传递的数据(REST没有类似的东西 - 尚未)。 另一方面,您不能仅使用浏览器浏览到wsHttpBinding端点并查看XML - 您必须使用SOAP客户端,例如WcfTestClient或您自己的应用程序。
因此,您的第一个决定必须是:REST vs. SOAP(或者您可以从服务中公开这两种类型的端点 - 这也是可能的)。
然后,在basicHttpBinding和wsHttpBinding之间,它们的区别如下:
basicHttpBinding是非常基本的绑定 - SOAP 1.1,安全性不高,功能方面也不多 - 但与任何SOAP客户端兼容-->非常适合互操作性,但在功能和安全性上比较弱
wsHttpBinding是全功能绑定,支持大量的WS-*功能和标准 - 它具有更多的安全功能,您可以使用会话连接,您可以使用可靠性消息传输,您可以使用事务控制-只有更多的东西,但wsHttpBinding也非常“重”,并且在消息在网络上传输时会增加很多开销
要进行深入比较(包括表格和代码示例),请查看此CodeProject文章:Differences between BasicHttpBinding and WsHttpBinding
restHttpBinding
而不是webHttpBinding
,那么这样做是否有问题?那会更加具有信息性。 - Jim AhoIt will depend on the usage and when the specific binding can be chosen
BasicHttpBinding -->Use this when you need very minimal security and reliability and the need is to extend the legacy classic ones and get them migrated to the new WCF world without much hassle.
WsHttpBinding-->Use this when you want message and transport level security along with reliability. Along with this it also has dual transactions and all option in case we need duplex level of work in project
WebHttpBinding-->Use this when the need is only on HTTP protocol and it will be using Verbs like Get, Put , Post , Delete and just like Asp.Net WebAPI usage we need to use this type of binding.
Hope this helps.