Prerequisites: Understanding WCF in depth Part – 1 , Understanding WCF in depth Part – 2
In this part, we will look at why endpoints were required?
From the previous article, we know the actual layers of channel stack, thus to build the channel stack configuration; ordering is important. This again is a tedious process and to remove this problem, WCF provides a concept called as Endpoints.
Now what is Endpoints?
For simplicity, let us assume that you want to deliver a message or a parcel to your friend. What you generally do is:
- Determine what the parcel is
- Pack it and write the address (where) on the Parcel for delivery
- Determine how you want to send the parcel, e.g. air, rail, road, etc.
The same process is followed when you want to send a message using WCF. You create an Endpoint.
Endpoints consists of 3 fundamental things (ABCs of WCF),
- Address: As to where you want to send the Message. Endpoint consists of Uri: which represents the address of the service and Identity: which represents the security identity of the service and a collection of optional message headers.
- Binding: How you want to send the Message (e.g., HTTP, TCP, etc.). The Binding provides the recipe for building the channel stack. For binding, you would need to define the Protocol (Context flow settings, security, and reliability), Transport (TCP, HTTP etc.) and Message Encoding (Text, Binary, MTOM).
- Contract: What message you want to send and how it is exposed to the client. It specifies what operations can be called by a client, the form of the message, the type of input parameters or data required to call the operation and what type of processing or response message the client can expect.
A sample Endpoint through web.config is as shown below:
<endpoint address="http://localhost:8001/hello/servicemodelsamples"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
There are different types of bindings available, we will look at the features in brief of the most commonly used bindings:
- BasicHttpBinding
- Interoperability
- Uses HTTP for Transport and Text for Encoding using SOAP 1.1 standard
- Transport/Message security
- Simple Channel Stack thus simple to implement
- WSHttpBinding
- Interoperability + richer web service protocol for security, message & transactions
- HTTP for transport & text encoding using SOAP 1.2 and WS Addressing 1.0
- Message security
- Sophisticated channel stack, thus used majorly for enterprise scenarios where integration across Framework and platform is required.
- NetTcpBinding
- No Interoperability
- TCP for transport and binary message encoding using SOAP 1.2
- Transport security
- Better performance channel stack for COM+ and .NET remoting components
- CustomBinding: While building Custom Binding, one needs to maintain the sequence which is shown below, the ones with “Required” are mandatory and should be defined.
- Transaction Flow
- Reliable Messaging
- Message security
- Composite Duplex
- Message Encoding –Required
- Transport Security
- Transport — Required
In the next post, we will look at some of the Contracts and its usage. :)