Tuesday, January 26, 2010

WCF Bindings

Binding: How do I communicate to the service?


· Binding provides information on how a service can be accessed including transport method (HTTP / HTTPS / TCP / Named pipe / MSMQ), encoding format (Text / Binary /MTOM), security mechanism, reliability requirement etc...

 - A service to be accessible, at least it should be associate with either one or more bindings.
- A contract can support many bindings and a binding can support many contracts.
· Out of the box, Indigo support following bindings which covers most of the common scenarios.
- Developers can create their own custom binding based on their requirement with the mix of functionality.

Bindings ship with WCF
  • basicHttpBinding - Suitable for communicating with WS-Basic Profile conformant Web services
  • wsHttpBinding - Secure and interoperable binding that is suitable for nonduplex service contracts.
  • wsDualHttpBinding - Secure and interoperable binding that is suitable for duplex service contracts. 
  • wsFederationHttpBinding - Secure and interoperable binding that supports the WS-Federation protocol 
  • netTcpBinding - Secure and optimized binding suitable for cross-machine communication between WCF applications. 
  • netNamedPipeBinding - Secure, reliable, optimized binding that is suitable for on-machine communication between WCF applications. 
  • netMsmqBinding - A queued binding that is suitable for cross-machine communication between WCF applications. 
  • netPeerTcpBinding - A binding that enables secure, multimachine communication. 
  • msmqIntegrationBinding - A binding that is suitable for cross-machine communication between a WCF application and existing Message Queuing applications. 
  • webhttpbinding is a new Web Friendly Binding which is used for services that are exposed through HTTP requests (Not through SOAP).

 Let's see a quick example:


In the above configuration, you can see we have multiple endpoints which expose the contract: MyExample.IBook.


Endpoint 1 : Address is Empty, which means which will take the base address. Binding is wsHttpBinding.
End Point 2: Address is having "/basic" which implies the address is: http://localhost:8000/example/service/basic. Binding is basicHttpBinding.
Endpoint 3: NamedPipe Address and binding.
Endpoint 4: TCPIP Address and related binding.


 The above simple configuration is enough to expose your service different way.

WCF provides key characteristics like Transport Neutral (Http, TCP, MSMQ and Named Pipes), various security features, multiple messaging patterns (simplex, duplex and request reply), encodings (text, binary or MTOM), network topologies, and hosting models (Windows, Windows NT Service, Console and IIS).

The above example shows you the that how WCF is one single programming model and runtime which unifies of existing .NET Framework communication technologies like ASMX, Remoting, Enterprise Services, WSE, MSMQ etc...

No comments: