Reader Level:
ARTICLE

WCF - Address, Binding and Contract: Day 10

Posted by Akshay Patel Articles | WCF with C# October 19, 2012
In this article we will discuss endpoints which consists of Address, Binding and Contract.
  • 8
  • 0
  • 15162

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

  1. Day 1 - WCF Introduction and Contracts
  2. Day 2 - WCF Fault Contracts
  3. Day 3 - WCF Message Exchange Patterns
  4. Day 4 - WCF DataContract
  5. Day 5 - WCF Difference between service application and service library
  6. Day 6 - WCF Serialization Part 1
  7. Day 7 - WCF Serialization Part 2
  8. Day 8 - WCF Opt-In VS Opt-Out
  9. Day 9 - WCF Message Contract

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 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.jpg

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:

Address.jpg

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.

COMMENT USING

Trending up