Mohammed Atef’s Technical blog

WCF Binding:BasicHttpBinding vs WsHttpBinding


The first thing developers starting to implement Windows Communication Foundation (WCF) should know the difference between the BasicHttpBinding and the WSHttpBinding.
This is very important as the BasicHttpBinding has some major drawbacks compared to the WSHttpBinding. From the functional view it makes no difference, it’s just a client invoking an operation on a service, but there is a world of difference concerning the low level exchange of SOAP packets to achieve this.


BasicHttpBinding is there only to support the old .ASMX style of working and aimed for clients which do not have .NET 3.0 installed. As lots of Windows 2000, which cannot run .NET 3.0, are still out there this is the only way to work with WCF. So the BasicHttpBinding it’s there mainly for compatibility reasons.
ASMX (without the WS enhancements) does not support secure messaging. When a client calls an operation on a service, all data in the payload is send as a plain XML, human readable, SOAP packet.
It also does not support reliability and ordered delivery.
When a call is lost somewhere, the client is not informed and just waits for a timeout and cannot know for sure if the call has arrived at the server and if the logic behind it got executed.
Also lacking in the basic profile is ordered delivery. This means when a client fires multiple calls to the service it’s not guaranteed that they arrive in the same order. Maybe somewhere a router could drop a packet allowing the second call to arrive earlier than the retransmission of the first. This can lead to disasters, which cannot be allowed in enterprise solutions.

The WSHttpBinding fully supports these requirements on security, reliability and ordered delivery. Some of them as default, others have to be configured.
WSHttpBinding uses (as the name implies) the WS-* protocols. This results in having some additional handshake messaging and This means that not only SOAP requests are sent for the operation calls but also to have the client and service agree on some context and to inform each other on the success of the calls.

WCF Code
I have created new WCF service for clarifying the difference between them. My WCF example is very simple it just one class contain one method which calculate the age by taking birthday as string parameter. You can find it in the below list of codes  
    interface ITestServiceContract
        int GetAge(string aString);

    class TheService : ITestServiceContract
        public int GetAge(string aString)
        {            Return “25”;        }  


Here you can find the request and response xml message using BasicHttpBinding
Request sample

<s:Envelope xmlns=””&gt;
    <GetAge xmlns=””><aDateTime>01/01/1983</aDateTime></GetAge&gt;

Response sample

<s:Envelope xmlns=””&gt;
    <GetAgeResponse xmlns=””&gt; <GetAgeResult>25</GetAgeResult></GetAgeResponse>

Now you can notice that this xml messages is very simple no security no encryption also it does not has acknowledge of the arriaval.
Also you can see the request and response using WSHttpBinding in the below image

WCF Binding: BasicHttpBinding vs WsHttpBinding

WCF Binding: BasicHttpBinding vs WsHttpBinding

As said, this behavior comes for free by using WCF, the developer does not have to know how this is done. Compared the ASMX this is a huge step forward. It would be hard to develop this yourself without WCF and if you would succeed in this is, it would be influencing the functional code.
Now you can see the difference between them for reliability and ordering from the below image

WCF Binding: BasicHttpBinding vs WsHttpBinding order

WCF Binding: BasicHttpBinding vs WsHttpBinding order

For BasicHttpBinding you can notice that the request and response done without any acknowledge or ordering.
But for  WSHttpBinding you will find hand check context for acknowledge and ordered responses for each request.

I hope this help.


May 19, 2009 - Posted by | WCF | , ,


  1. nice comparison, thanks for sharing

    Comment by usman shaheen | May 22, 2009 | Reply

  2. Thank you for your comment but it will be very nice if you write post about using this two types of binding in old work before

    Comment by mohammedatef83 | May 24, 2009 | Reply

  3. This is really useful even for a non hard core developer..

    Comment by Sam | March 3, 2010 | Reply

    • Thank you for comment

      Comment by mohammedatef83 | March 4, 2010 | Reply

  4. Nice article…explains the difference between the two binding types in a nice way

    Comment by sumanta | February 17, 2011 | Reply

  5. It is very nice explain and very useful. Thanks

    Comment by Dhinesh | July 7, 2011 | Reply

    • Dear,
      Thank you for your comment and you are welcome

      Comment by mohammedatef83 | July 10, 2011 | Reply

  6. Thanks, really nice comparision

    Comment by Dhyanesh | October 5, 2011 | Reply

  7. Nice article

    Comment by Rabiul | July 17, 2012 | Reply

    • Thank you for your comment…

      Comment by mohammedatef83 | July 19, 2012 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: