Windows Communication Foundation BindingsThis article offers a brief explanation on the basic concepts of the Communication part in the
Windows Communication Foundation - WCF. In order to communicate with a WCF service, the client needs to know simple details like 'ABC' of the service.
Whats meant by ABC of WCF ?Before we learn the ABC of WCF, we need to know how a WCF service is made accessible to the clients.
A WCF service allows communication through an Endpoint. And the endpoint is the only point of communication of the WCF service that enables message exchange with the client as shown in below figure.
And this Endpoint needs to set the ABC attributes of the WCF service as shown in the below figure.
Thus in the WCF world, ABC is an abbreviation of
Address,
Binding and
Contract attributes of an Endpoint.
An example of the EndpointLet us quickly run through an example of an endpoint setting in the
web.config file at the service side.
<endpoint
address="http://localhost:8731/EmpWCFService.ServiceImpl.Manager/"
binding="basicHttpBinding"
contract="EmpWCFService.ServiceContract.IEmployee" />
Where,
- address is the network address of the service,
- binding specifies transport protocol (HTTP, TCP, etc.) selected for the service &
- contract is the interface the service implements.
So, what is the Binding?The Binding is an attribute of an endpoint and it lets you configure transport protocol, encoding and security requirements as shown in the below figure.
Types of BindingWCF supports nine types of bindings. WCF allows you to transmit messages using different transport protocols (such as HTTP, TCP, and MSMQ) and using different XML representations (such as text, binary, or MTOM).
- Basic binding - BasicHttpBinding
- It is suitable for communicating with ASP.NET Web services (ASMX)-based services that comfort with WS-Basic Profile conformant Web services.
- This binding uses HTTP as the transport and text/XML as the default message encoding.
- Security is disabled by default
- This binding does not support WS-* functionalities like WS- Addressing, WS-Security, WS-ReliableMessaging
- It is fairly weak on interoperability.
- Web Service (WS) binding - WSHttpBinding
- Defines a secure, reliable, interoperable binding suitable for non-duplex service contracts.
- It offers lot more functionality in the area of interoperability.
- It supports WS-* functionality and distributed transactions with reliable and secure sessions using SOAP security.
- It uses HTTP and HTTPS transport for communication.
- Reliable sessions are disabled by default.
- TCP binding - NetTcpBinding
- This binding provides secure and reliable binding environment for .Net to .Net cross machine communication.
- By default it creates communication stack using WS-ReliableMessaging protocol for reliability, TCP for message delivery and windows security for message and authentication at run time.
- It uses TCP protocol and provides support for security, transaction and reliability.
- MSMQ binding - NetMsmqBinding
- This binding provides secure and reliable queued communication for cross-machine environment.
- Queuing is provided by using MSMQ as transport.
- It enables for disconnected operations, failure isolation and load leveling
- Peer network binding - NetPeerTcpBinding
- This binding provides secure binding for peer-to-peer environment and network applications.
- It uses TCP protocol for communication
- It provides full support for SOAP security, transaction and reliability.
- Duplex WS binding - WSDualHttpBinding
- This binding is same as that of WSHttpBinding, except it supports duplex service.
- Duplex service is a service which uses duplex message pattern, which allows service to communicate with client via callback.
- In WSDualHttpBinding reliable sessions are enabled by default. It also supports communication via SOAP intermediaries.
- IPC binding
- Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding.
- Federated WS binding
- Offered by the WSFederationHttpBinding class, this is a specialization of the WS binding, offering support for federated security.
- MSMQ integration binding
- Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients.
That's all at this moment. Will see more in the next post.
Thanks : wcftutorial.net & c-sharpcorner.com