3 March 2014

WCF Fundamentals


 Endpoint:
         WCF Service is a program that exposes a collection of Endpoints. Each Endpoint is a portal for communicating with the outside world. All the WCF communications are take place through end point. End point consists of three components.

Address:

      Basically URL specifies where this WCF service is hosted .Client will use this URL to connect to the service.

Example: http://localhost:8090/MyService/SimpleCalculator.svc

Binding:

       Binding will describes how client will communicate with service. There are different protocols available for the WCF to communicate to the Client. You can mention the protocol type based on your requirements.

Bindings have following properties:

  • Transport -Defines the base protocol to be used like HTTP, Named Pipes, TCP, and MSMQ are some type of protocols.
  • Encoding (Optional) - Three types of encoding are available-Text, Binary, or Message Transmission Optimization Mechanism (MTOM). MTOM is an interoperable message format that allows the effective transmission of attachments or large messages (greater than 64K).
  • Protocol(Optional) - Defines information to be used in the binding such as Security, transaction or reliable messaging capability
Bindings Supported by WCF :

Binding
Description
BasicHttpBinding
Basic Web service communication. No security by default
WSHttpBinding
Web services with WS-* support. Supports transactions
WSDualHttpBinding
Web services with duplex contract and transaction support
WSFederationHttpBinding
Web services with federated security. Supports transactions
MsmqIntegrationBinding
Communication directly with MSMQ applications. Supports transactions
NetMsmqBinding
Communication between WCF applications by using queuing. Supports transactions
NetNamedPipeBinding
Communication between WCF applications on same computer. Supports duplex contracts and transactions
NetPeerTcpBinding
Communication between computers across peer-to-peer services. Supports duplex contracts
NetTcpBinding
Communication between WCF applications across computers. Supports duplex contracts and transactions
Contract:

      It specifies what operations are to be exposed to client. Each operation has certain data exchange pattern such as one-way, duplex and request reply. It also specifies which end point will expose what operations

Below figure describes the functions of End points:


Example:

      Endpoints will be mentioned in the Web.Config file on the created service.
        <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