313

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?

Mubashar
  • 12,300
  • 11
  • 66
  • 95

3 Answers3

537

You're comparing apples to oranges here:

  • 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 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.

So your first decision must be: REST vs. SOAP (or you can expose both types of endpoints from your service - that's possible, too).

Then, between basicHttpBinding and wsHttpBinding, there differences are as follows:

  • 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 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

For an in-depth comparison (including a table and code examples) between the two check out this codeproject article: Differences between BasicHttpBinding and WsHttpBinding

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    I am not taking any decisions here dear i just wanted to know the difference you must know what is the taste of orange and the same of apple that is why i asked this question. I need more about WebHttpBinding in term of feature comparisons and performance – Mubashar Apr 16 '10 at 05:56
  • Check out Google or Bing and search for "REST vs. SOAP" - **LOADS** of information out there! – marc_s Apr 16 '10 at 06:00
  • 4
    One correction: wsHttpBinding doesn't support streaming. Or am I missing something? http://msdn.microsoft.com/en-us/library/ms730879.aspx – Andrew Shepherd Nov 21 '10 at 22:35
  • 1
    @Andrew Shepherd: thanks for the link and the correction - you're absolutely right, wsHttpBinding does not support streaming..... – marc_s Nov 22 '10 at 06:21
  • @EduardoLeón One of the tenants of REST is to take advantage of features built into HTTP. Authentication is built into HTTP, so you could potentially use ANY type of authentication provider you wanted. It could be as simple as Basic or NTLM, or you could do something more advanced which leverages OAuth/STS tokens, etc. – BrainSlugs83 Oct 21 '12 at 06:01
  • Would it be wrong if they had named it `restHttpBinding` instead of `webHttpBinding`? That'd be so much more informative. – Jim Aho Mar 04 '16 at 10:58
  • @JimAho: **naming is hard** - one of the two classic problems in computer science (besides cache invalidation) .... – marc_s Mar 04 '16 at 11:17
  • The supposed lack of "interoperability" on `wsHttpBinding` makes me nervous. Does anyone have a feeling for just how many clients would be unable to connect? It almost seems like you should only go that approach if you have a clearer idea of what your target client is. – Savage Apr 05 '16 at 08:42
0

If your are getting missing service namespace reference when copying your files to the web server, try the following. We found that publishing the project and copying out the App_WebReference.dll file in to the bin folder will fix that. Using the bindings that are generated from adding the service into your project found in the web.config can then be copied to your servers web.config .

Nathan
  • 1
0
It 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.