问题描述
在WCF中,有几种不同类型的基于HTTP的绑定:
In WCF there are several different types of HTTP based bindings:
- BasicHttpBinding
- WsHttpBinding
- WebHttpBinding
这三个之间有什么区别?
What are the differences among these 3?
特别是在功能/性能和兼容性方面有什么区别?
In particular what are the differences in terms of features / performance and compatability?
推荐答案
您在这里将苹果与橙子进行比较:
You're comparing apples to oranges here:
-
webHttpBinding 是REST样式的绑定,您基本上只需单击URL并从Web服务中获取大量XML或JSON
webHttpBinding is the REST-style binding, where you basically just hit a URL and get back a truckload of XML or JSON from the web service
basicHttpBinding 和 wsHttpBinding 是两个基于SOAP的绑定,与REST完全不同. SOAP的优点是可以使用WSDL和XSD来详细描述服务,其方法以及要传递的数据(REST还没有类似的东西).另一方面,您不能只使用浏览器浏览到wsHttpBinding端点并查看XML-您必须使用SOAP客户端,例如WcfTestClient或您自己的应用.
basicHttpBinding and wsHttpBinding are two SOAP-based bindings which is quite different from REST. SOAP has the advantage of having WSDL and XSD to describe the service, its methods, and the data being passed around in great detail (REST doesn't have anything like that - yet). On the other hand, you can't just browse to a wsHttpBinding endpoint with your browser and look at XML - you have to use a SOAP client, e.g. the WcfTestClient or your own app.
因此,您的第一个决定必须是:REST vs. SOAP(或者也可以从服务中公开两种类型的端点-也可以).
So your first decision must be: REST vs. SOAP (or you can expose both types of endpoints from your service - that's possible, too).
然后,basicHttpBinding和wsHttpBinding之间存在如下差异:
Then, between basicHttpBinding and wsHttpBinding, there differences are as follows:
-
basicHttpBinding是非常基本的绑定-SOAP 1.1,在安全性方面没有太大的限制,在功能方面没有太多其他的限制-但与那里的任何SOAP客户端兼容->互操作性很好,弱点功能和安全性
basicHttpBinding is the very basic binding - SOAP 1.1, not much in terms of security, not much else in terms of features - but compatible to just about any SOAP client out there --> great for interoperability, weak on features and security
wsHttpBinding是成熟的绑定,它支持大量的WS- *功能和标准-它具有更多的安全性功能,可以使用会话连接,可以使用可靠的消息传递,可以使用事务控制-还有很多东西,但是wsHttpBinding也繁重",并且在您的邮件通过网络传播时会增加很多开销
wsHttpBinding is the full-blown binding, which supports a ton of WS-* features and standards - it has lots more security features, you can use sessionful connections, you can use reliable messaging, you can use transactional control - just a lot more stuff, but wsHttpBinding is also a lot *heavier" and adds a lot of overhead to your messages as they travel across the network
有关两者之间的深入比较(包括表和代码示例),请查看此代码项目文章: BasicHttpBinding和WsHttpBinding之间的区别
For an in-depth comparison (including a table and code examples) between the two check out this codeproject article: Differences between BasicHttpBinding and WsHttpBinding
这篇关于BasicHttpBinding与WsHttpBinding与WebHttpBinding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!