WCF - Address, Binding and Contract: Day 10

In this article, we will discuss endpoints which consists of Address, Binding and Contract.

This is the Day 10 article. If you have not read the previous articles then please go through the following articles:

Introduction

 
In this article, we will discuss endpoints which consists of Address, Binding and Contract. 
 
In previous articles, we have seen about ServiceContract, OperationContract, and implementation of these in the service class. In this implementation, we write business logic. Services expose endpoints to the world. There may be multiple endpoints in a service. Endpoints define communication options. 
 
WCF–Address-Binding-Contract.jpg 
 

Endpoint

 
An Endpoint is a piece of information that tells WCF how to build the runtime communication channels to send and receive messages. An endpoint consists of the three things address, binding and contract.
 
Endpoint 
 

Address

 
Address - Where - Where to send messages
 
An Address is a unique Uniform Resource Locator (URI) that identifies the location of the service. It defines the network address for sending and receiving the messages. It is divided into four parts:
 
EndPoint Address 
 

Binding

 
Binding - How - How to send messages
 
A Binding specifies which transport protocol to use, what message format and which any of the ws* protocols we want to use to a particular endpoint.
 
BasicHttpBinding
  • Replacement for earlier Web Service basedon ASMX (Active Server Methods)
  • Supports:
    • HTTP - Hypertext Transfer Protocol
    • HTTPS - Hypertext Transfer Protocol over SSL
    • MTOM - Message Transmission Optimization Mechanism encoding methods.
wsHttpBinding
  • Uses SOAP over HTTP and supportsreliability, transactions and security over the internet.
  • Supports:

    • HTTP - Hypertext Transfer Protocol
    • HTTPS - Hypertext Transfer Protocol over SSL
    • MTOM - Message Transmission Optimization Mechanism encoding methods.
wsDualHttpBinding
  • Used for duplex service contract becauseit supports bidirectional communication.
webHttpBinding
  • Sends information directly over HTTP orHTTPS without creating a SOAP envelope
  • It is a good choice when SOAP is notrequired by the client
NetTcpBinding
  • Used to send binary-encoded SOAP messagesfrom one computer to another
  • Uses TCP (Transmission Control Protocol)and includes support for reliability, transactions and security
NetPeerTcpBinding
  • Used for peer-to-peer communication overTCP
  • Communication should occur between two ormore computers
netNamedPipeBinding
  • Binary encoded SOAP messages are sentover named pipes
  • Used on a single WCF computer
netMSMQBinding
  • Queued binding is used to sendbinary-encoded SOAP messages over MSMQ
  • Communication should occur between twocomputers

Contract

 
A Contract provides the additional detail about the structuring contents of the various messages that will be used by the various operations exposed to the particular endpoints. For example we create a service "TopupService", the interface used to define the service is "ITopupService" and the project name is "Utility". The contract for this service would be Utility.ITopupService.