ABCs of an EndPoint in WCF

Objective:

This article is targeted to beginners in WCF. This is a totally theoretical article. It will explain:

  1. All the theoretical concepts of an EndPoint in WCF.
  2. Addresses in WCF
  3. Binding and where, which binding should be used.
  4. Contracts.

ABCs of Endpoints in WCF

The three elements of an endpoint starts with letters that make a mnemonic phrase.

"ABCs of Endpoints"

image1.gif


image2.gif
image3.gif

Address of an Endpoint(A)

image4.gif

  1. A address specifes where the service is residing.
  2. This is a Uniform Resource Locator (URL).
  3. The address URL identifies the location of the service.
  4. The address should folllow the "Web Service Addressing" (WS-Addressing) standard.

    image5.gif

    image6.gif

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:

image7.gif

Binding of an Endpoint (B)

The Binding is how the service is to be used. The Binding specifies:

  1. Which protocol to use.
  2. Which encoding to use.
  3. 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:

  1. This is interoperable binding.
  2. This is commonly used as a replacement for earler web services based on ASMX.
  3. It supports HTTP & HTTPS protocols.
  4. It supports MTOM encoding.
  5. It supports text encoding.

The following describes wsHttpBinding:

  1. This is a secure binding.
  2. This is interoperable binding.
  3. This uses SOAP over HTTP.
  4. This supports reliability over internet.
  5. This supports transaction over internet.
  6. This supports security over internet.
  7. This supports HTTP/HTTPS proptcol
  8. This supports text and MTOM encoding.
  9. This is default binding provided by WCF.

The following describes wsDualHttpBinding:

  1. This supports all the features of wsHttpBinding.
  2. This is mainly used for DUPLEX SERVICE CONTRACTS.
  3. This supports bidirectional communication.

The following describes webHttpBinding:

  1. This is a secure binding.
  2. This is a interoperable binding.
  3. It supports Http/Https protocol.
  4. It does not use SOAP message format.

    image8.gif

The following describes wsFederationHttpBinding:

  1. This is a secure Binding.
  2. This is interoperable binding.
  3. This supports federated security
  4. This supports Https/Https protocols.
  5. This uses text/MTOM encoding.

    image9.gif

The following describes netTCPBinding:

  1. This is a secure Binding.
  2. This could only be used if the client is also a WCF machine.
  3. This is used to send Binary encoded SOAP messages from one WCF computer to another.
  4. This uses Transimission Control Protocol (TCP).
  5. This supports reliability.
  6. This supports transaction.
  7. This supports security.

The following describes netNamedPipeBinding:

  1. This is a secure Binding.
  2. This could be used over a single WCF computer.
  3. This sends Binary encoded SOAP message over named pipes.

The following describes netMSMQBinding:

  1. This is a queued Binding.
  2. This uses Binary encoded SOAP message.
  3. This sends message over MSMQ.
  4. Here the communication should occur between two computers.

The following describes netPeerTCPBinding:

  1. This is a secure Binding.
  2. This uses TCP over peer to peer.
  3. The Communication should occur between two or more computers.

The following describes msmqIntegrationBinding:

image10.gif

basicHttpContextBinding

This Binding is the same as basicHttpBinding except with more attributes, as in the following:

  1. It supports HTTP cookies
  2. It eanbles SOAP haeders to exchange context.
  3. This binding is mainly used for Durable services.

netTCPContextBinding

This Binding is the same as netTCPBinding except with more attributes, as in the following

  1. It eanble SOAP haeders to excahnge context.
  2. This binding is mainly used for Durable services.

wsHttpContextBinding

This Binding is the same as wsHttpBinding with more attributes, as in the following:

  1. It eanble SOAP haeders to excahnge context.
  2. 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)

image12.gif

  1. The contract should be an Interface
  2. The contract could be a class also but the better approach is interface.
  3. In the config file this is preceded by prpject name space name

<endpoint  address="" binding="wsHttpBinding" contract="WcfService2.IService1">

Up Next
    Ebook Download
    View all
    Learn
    View all