Thursday, April 28, 2016

WCF Part 2 : Endpoints & Contract


Windows Communication Foundation (WCF) 

Chapter 2: Fundamentals

  • End Point 
  • Bindings and Behavior 
  • Contracts and Service host 
  • Message and Channel 
  • WCF client and Metadata
END Point 
A web service endpoint is an entity, processor, or resource that can be referenced and to which web services messages can be addressed. 
Endpoint references convey the information needed to address a web service endpoint. Clients need to know this information before they can access a service.

Endpoint consists 3 components

Address
Specifies where service is hosted, it is basically a web address.
Ex. http://localhost:8090/MyService/SimpleCalculator.svc

Binding

Binding describes how client communicate with the service.

Binding has several characteristics

Transport : Defines protocol like HTTP, TCP, MSMQ etc.
Encoding : Text, Binary, Message Transmission and Optimization Mechanism.
Protocol : Defines information to be used in the binding such as Security, transaction or reliable messaging capability.


The following table gives some list of protocols supported by WCF binding.

BindingDescription
BasicHttpBindingBasic Web service communication. No security by default
WSHttpBindingWeb services with WS-* support. Supports transactions
WSDualHttpBindingWeb services with duplex contract and transaction support
WSFederationHttpBindingWeb services with federated security. Supports transactions
MsmqIntegrationBindingCommunication directly with MSMQ applications. Supports transactions
NetMsmqBindingCommunication between WCF applications by using queuing. Supports transactions
NetNamedPipeBindingCommunication between WCF applications on same computer. Supports duplex contracts and transactions
NetPeerTcpBindingCommunication between computers across peer-to-peer services. Supports duplex contracts
NetTcpBindingCommunication between WCF applications across computers. Supports duplex contracts and transactions

Contract

Collection of operation that specifies what the endpoint will communicate with outside world. Usually name of the Interface will be mentioned in the Contract, so the client application will be aware of the operations which are exposed to the client. 
Each operation is a simple exchange pattern such as one-way, duplex and request/reply.


<system.serviceModel>
<services>
      <service name="MathService"
        behaviorConfiguration="MathServiceBehavior">
       <endpoint
         address="http://localhost:8090/MyService/MathService.svc" contract="IMathService"
          binding="wsHttpBinding"/> 
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MathServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

No comments:

Post a Comment