In WCF there are several different types of HTTP based bindings:
What are the differences among these 3?
In particular what are the differences in terms of features / performance and compatability?
In WCF there are several different types of HTTP based bindings:
What are the differences among these 3?
In particular what are the differences in terms of features / performance and compatability?
您在这里将苹果与橙子进行比较:
webHttpBinding是 REST 样式的绑定,您基本上只需点击一个 URL 并从 Web 服务获取一卡车的 XML 或 JSON
basicHttpBinding和wsHttpBinding是两个与 REST 完全不同的基于 SOAP 的绑定。SOAP 的优点是使用 WSDL 和 XSD 来详细描述服务、它的方法和传递的数据(REST 还没有这样的东西)。另一方面,您不能只用浏览器浏览到 wsHttpBinding 端点并查看 XML - 您必须使用 SOAP 客户端,例如 WcfTestClient 或您自己的应用程序。
因此,您的第一个决定必须是:REST 与 SOAP(或者您可以从您的服务公开这两种类型的端点 - 这也是可能的)。
那么basicHttpBinding和wsHttpBinding的区别如下:
basicHttpBinding 是非常基本的绑定 - SOAP 1.1,在安全性方面不多,在功能方面也不多 - 但几乎与任何 SOAP 客户端兼容 --> 非常适合互操作性,功能和安全性较弱
wsHttpBinding 是一个成熟的绑定,它支持大量的 WS-* 特性和标准——它有更多的安全特性,你可以使用会话连接,你可以使用可靠的消息传递,你可以使用事务控制——只是更多的东西,但是 wsHttpBinding 也更“重”,并且在消息通过网络传输时会增加很多开销
有关两者之间的深入比较(包括表格和代码示例),请查看此代码项目文章:BasicHttpBinding 和 WsHttpBinding 之间的差异