Mubashar
Mubashar

Reputation: 12658

BasicHttpBinding vs WsHttpBinding vs WebHttpBinding

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?

Upvotes: 320

Views: 183684

Answers (3)

Priya Maheshwari
Priya Maheshwari

Reputation: 35

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.

Upvotes: 0

Nathan
Nathan

Reputation: 1

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 .

Upvotes: 0

marc_s
marc_s

Reputation: 754458

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

Upvotes: 546

Related Questions