WCF - Address, Binding and Contract: Day 10

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 based on 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 supports reliability, 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 because it supports bidirectional communication.
webHttpBinding
  • Sends information directly over HTTP or HTTPS without creating a SOAP envelope
  • It is a good choice when SOAP is not required by the client
NetTcpBinding
  • Used to send binary-encoded SOAP messages from one computer to another
  • Uses TCP (Transmission Control Protocol) and includes support for reliability, transactions and security
NetPeerTcpBinding
  • Used for peer-to-peer communication over TCP
  • Communication should occur between two or more computers
netNamedPipeBinding
  • Binary encoded SOAP messages are sent over named pipes
  • Used on a single WCF computer
netMSMQBinding
  • Queued binding is used to send binary-encoded SOAP messages over MSMQ
  • Communication should occur between two computers

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.
 


Similar Articles