WCF Part 7: bindings

Source: Internet
Author: User

As I 've been pretty busy, it's been a while since my last post in the WCF series. but let's have a look at bindings now. A binding will tell a client what's necessary to connect to the service. in other words, how we connect is described by the binding. as you can see in the image, this is composed from the protocols selected, the chosen encoder and chosen transport. 

 

the image also shows the architecture of WCF. the service-host initiates one or more dispatchers. in configuration you setup the protocols, encoder and transport to use, per endpoint. at the client side you do this as well. when a message is sent from client to service, it first goes through the (generated) proxy, through configured protocols, encoder and finally will be sent over a transport layer. on the other end, the same happens, but the other way around.

    1. protocols
      these can be anything, but some of the default delivered with WCF are, for example, reliable messaging or transactions. when the message shocould be encrypted, it's done in this layer.
    2. encoder
      This is text/XML for HTTP bindings, But binary XML for the TCP binding.
    3. transport
      This can be HTTP or TCP, namedpipes or MSMQ.

Depending on what you actually want and need, you 'd normally decide which binding is best for your situation. Using the demo-chart I 've shown inThis post, You can see what bindings are available and when to choose what. In the following table you can see some abilities and which binding supports them. 

 

first you see InterOP. if you choose a transport other than HTTP, WCF cannot InterOP with another platform as these just don't support them. with basichttpbinding your service can communicate with clients that conform to the WS-basic profile. everyone understanding WebServices can communicate with basichttpbinding. wshttpbinding can be seen as a basic profile WebService with WSE 3.0 encoded ded. so while it's still interoperable, with more abilities, it's harder for external platforms to setup and communicate with your service, although if those external platforms are conform to the WS-* specs, They shocould be able to communicate with you. I 've already seen this working with asmx/wse3.0, Java, etc.

All bindings but one support both transport (T) and message (s) Security. we'll get back to that in another post. but it basically means if you choose basichttpbinding, your only possible option to secure your service is, for example, via SSL, meaning you'll get an https: // address.

Bindings that have a cross-mark at sessions, support... well, sessions. the same goes for transactions. i'll get back to all this later in the series. duplex means the service and client can send messages back and forth, for example to give status updates during long running requests.

of course the above list can be altered by extending WCF. I probably won't go into details, as extending WCF gets a lot of attention all over the Internet. an example extension cocould be creating a new transport-layer to support sending messages over SMTP, ftp or whatever you can think. microsoft uses the example to add transport and encoding layers so clients will be able to talk directly to external systems that don't know anything about WCF. but I think it's far more likely that a service-interface will be created on top of these systems, exposing it through WCF using the default and regular bindings.

The great thing about WCF and these bindings is, that in theory you can deploy a service and afterwards add, offer and support other endpoints. for example start with basichttpbinding and add nettcpbinding later. with the demos used in my previous articles, this is possible without any modification to the code.

Although this article discusses bindings, we'll definitely get back to things like security, transactions, etc. But these are all topics on their own and deserve one or more posts in this WCF series. 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.