Learning Center
Plans & pricing Sign in
Sign Out

Windows Communication Foundation (wcf)


Windows Communication Foundation (wcf)

More Info
In Windows Communication Foundation your
services can have communication with clients
by sending and receiving messages
          Architecture of Windows

Foundation consists of five layers.
1. Application: In this level application is located.
2.Contracts: In the second layer service, data and
  message contracts as well as bindings and
  policies are present. In this level services
  describe themselves to clients.
3. Runtime: Behaviors are located in this
  layer. Runtime layer loads all services.
3. Messaging: Different types of channels as
  well as encoders are here. This layer enables
  communications for services.
4. Hosting: This layer is where host services in
  different manners, but there are two common
  ways to host a service. You can host a
  service in Internet Information Services (IIS)
  which is easier than the second approach and
  starts and stops your services
  automatically. The second approach is to
  create executable files (.EXE) for services
  and start and stop them manually by writing
  more codes.
    To create wcf application
• Define contracts
• Implementing contracts
• Creating host and configure with a
• Configuring endpoint
• Configuring service
WCF includes four kinds of contracts
All four types of contracts translate between Microsoft
   .NET types used internally and the XML
   representations shared externally:
1. A service contract converts between the CLR and
   Web Services Description Language (WSDL)
2. A data contract converts between the CLR and XML
   Schema Definition (XSD)
3. A message contract converts between the CLR and
   Simple Object Access Protocol (SOAP)
4. A fault contract converts the CLR exceptions and to
   SOAP faults
   Understanding Endpoints

Services expose one or more endpoints
where messages can be sent. Each
endpoint consists of an address, a binding,
and a contract. The address specifies
where to send messages. The binding
describes how to send messages. And the
contract describes what the messages
             Understanding Bindings

The bindings of a WCF service define how an endpoint will
  communicate with an external client.

• Transport protocols - Some of the choices include HTTP,
  Named Pipes, TCP, and MSMQ.

• Encoding - 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).

• Security - Includes wire security (SSL) or schema-defined
  security (WS-Security).
  WCF build-in bindings and their associated features
Binding            Description
BasicHttpBinding   Basic Web service communication. No security by default
WSHttpBinding      Web services with WS-* support. Supports transactions
                   Web services with duplex contract and transaction support
                   Web services with federated security. Supports transactions
                   Communication directly with MSMQ applications. Supports transactions
NetMsmqBinding     Communication between WCF applications by using queuing. Supports
NetNamedPipeBin    Communication between WCF applications on same computer. Supports
   ding               duplex contracts and transactions
NetPeerTcpBindin   Communication between computers across peer-to-peer services. Supports
   g                  duplex contracts
NetTcpBinding      Communication between WCF applications across computers. Supports
                      duplex contracts and transactions
                           App.config File

<?xml version="1.0" encoding="utf-8" ?>
     <binding name="PortBinding" portSharingEnabled="true" />
     <behavior name="satya">

 <service name="mylibrary.Service1" behaviorConfiguration ="satya">
        <add baseAddress ="net.tcp://localhost:1111"/>
     <endpoint address="mylibrary.Service1" binding ="netTcpBinding"
contract ="mylibrary.IService1" />
     <endpoint address="mex" binding="mexTcpBinding"
contract="IMetadataExchange" />


What happens if same port is been used by applications running on TCP ?
NET.TCP Port sharing
Now through NET.TCP Port sharing service, multiple applications in WCF can
share the same ports.
Transfer security contains three options
            Integrity, Confidentiality, and Authentication

Integrity is the assurance that data is complete and accurate,
especially after it has traversed from one point to another, and
possibly been read by many actors. Integrity must be maintained to
prevent tampering with the data, and is usually achieved by digital
signing of a message

Confidentiality is the assurance that a message has not been
read by anyone other than the intended reader. For example, a credit
card number must be kept confidential as it is sent over the Internet.
Confidentiality is often provided by the encryption of data using a
public key/private key scheme.

 Authentication is the verification of a claimed identity. For
 example, when using a bank account, it is imperative that only the
 actual owner of the account be allowed to withdraw funds.
 Authentication can be provided by a variety of means. One common
 method is the user/password system.
               Security Modes

1. None : No security is provided at the transport layer or
   at the message layer. None of the predefined bindings
   use this mode by default except the <basicHttpBinding>
   element or, when using code, the BasicHttpBinding
2.   Tansport : Uses a secure transport such as HTTPS
     for integrity, confidentiality, and mutual authentication.
3. Message : Uses SOAP-message security for integrity, confidentiality, and
   mutual authentication. SOAP messages are secured according to the
   WS-Security standards
4. TransportWithMessageCredential :Uses transport security for integrity,
confidentiality, and server authentication. Uses message security (WS-
Security and other standards) for client authentication.
Transport Client Credential Types

1. None : Specifies that the client does not need to present any
   credential. This translates to an anonymous client.
2. Basic : Specifies basic authentication
3. Digest : Specifies digest authentication

4. Windows : Specifies Windows authentication using SSPI on a
   Windows domain. SSPI picks from either the Kerberos protocol or
   NTLM as authentication service. SSPI tries Kerberos protocol first;
   if that fails, it then uses NTLM.
5. Certificate :
  Message Client Credential Types

1. None : Allows the service to interact with anonymous clients.
2. Windows : Allows SOAP message exchanges to occur under
   the authenticated context of a Windows credential. Uses SSPI
   negotiation mechanism to pick from either the Kerberos
   protocol or NTLM as an authentication service.
3. Username : Allows the service to require that the client be
   authenticated with a user name credential. Note that WCF does
   not allow any cryptographic operations with the user name,
   such as generating a signature or encrypting data. As such,
   WCF enforces that the transport is secured when using user
   name credentials
4. Certificate : Allows the service to require that the client be
   authenticated using a certificate

To top