ABCs of Endpoints in WCF
The three elements of an endpoint starts with letters that make a mnemonic phrase.
"ABCs of Endpoints"
Address of an Endpoint(A)
-
A address specifes where the service is residing.
-
This is a Uniform Resource Locator (URL).
-
The address URL identifies the location of the service.
-
The address should folllow the "Web Service Addressing" (WS-Addressing) standard.
The address depends on whether it is hosted in IIS or a managed application or WAS. This also depends on the binding being used.
The following are example of various types of addresses:
Binding of an Endpoint (B)
The Binding is how the service is to be used. The Binding specifies:
-
Which protocol to use.
-
Which encoding to use.
-
What type of security requeiremnets are to be used, like SSL or SOAP message security.
System provided Bindings
The system-provided Bindings are basicHttpBinding, wsHttpBinding, wsDualHttpBinding, webHttpBinding, wsFederationHttpBinding, netTCPBinding, netNamedPipeBinding, netMSMQBinding, netPeerTCPBinding, msmqIntegrationBinding, basicHttpContextBinding, netTCPContextBinding and wsHttpContextBinding.
The following describes basicHttpBinding:
-
This is interoperable binding.
-
This is commonly used as a replacement for earler web services based on ASMX.
-
It supports HTTP & HTTPS protocols.
-
It supports MTOM encoding.
-
It supports text encoding.
The following describes wsHttpBinding:
-
This is a secure binding.
-
This is interoperable binding.
-
This uses SOAP over HTTP.
-
This supports reliability over internet.
-
This supports transaction over internet.
-
This supports security over internet.
-
This supports HTTP/HTTPS proptcol
-
This supports text and MTOM encoding.
-
This is default binding provided by WCF.
The following describes wsDualHttpBinding:
-
This supports all the features of wsHttpBinding.
-
This is mainly used for DUPLEX SERVICE CONTRACTS.
-
This supports bidirectional communication.
The following describes webHttpBinding:
-
This is a secure binding.
-
This is a interoperable binding.
-
It supports Http/Https protocol.
-
It does not use SOAP message format.
The following describes wsFederationHttpBinding:
-
This is a secure Binding.
-
This is interoperable binding.
-
This supports federated security
-
This supports Https/Https protocols.
-
This uses text/MTOM encoding.
The following describes netTCPBinding:
-
This is a secure Binding.
-
This could only be used if the client is also a WCF machine.
-
This is used to send Binary encoded SOAP messages from one WCF computer to another.
-
This uses Transimission Control Protocol (TCP).
-
This supports reliability.
-
This supports transaction.
-
This supports security.
The following describes netNamedPipeBinding:
-
This is a secure Binding.
-
This could be used over a single WCF computer.
-
This sends Binary encoded SOAP message over named pipes.
The following describes netMSMQBinding:
-
This is a queued Binding.
-
This uses Binary encoded SOAP message.
-
This sends message over MSMQ.
-
Here the communication should occur between two computers.
The following describes netPeerTCPBinding:
-
This is a secure Binding.
-
This uses TCP over peer to peer.
-
The Communication should occur between two or more computers.
The following describes msmqIntegrationBinding:
basicHttpContextBinding
This Binding is the same as basicHttpBinding except with more attributes, as in the following:
-
It supports HTTP cookies
-
It eanbles SOAP haeders to exchange context.
-
This binding is mainly used for Durable services.
netTCPContextBinding
This Binding is the same as netTCPBinding except with more attributes, as in the following
-
It eanble SOAP haeders to excahnge context.
-
This binding is mainly used for Durable services.
wsHttpContextBinding
This Binding is the same as wsHttpBinding with more attributes, as in the following:
-
It eanble SOAP haeders to excahnge context.
-
This binding is mainly used for Durable services.
Example :
<system.serviceModel>
<services>
<service name="WcfService2.Service1" behaviorConfiguration="WcfService2.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="WcfService2.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService2.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Contract of and EndPoint (C)
-
The contract should be an Interface
-
The contract could be a class also but the better approach is interface.
-
In the config file this is preceded by prpject name space name