WCF - Interview Questions Part 1

Jun 30, 2009 Posted by Lara Kannan
  1. What is WCF?
    Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows. WCF provides a runtime environment for services, enabling you to expose CLR types as services, and to consume other services as CLR types.

    WCF is part of .NET 3.0 and requires .NET 2.0, so it can only run on systems that support it. WCF is Microsoft's unified programming model for building service-oriented applications with managed code. It extends the .NET Framework to enable developers to build secure and reliable transacted Web services that integrate across platforms and interoperate with existing investments.

    Windows Communication Foundation combines and extends the capabilities of existing Microsoft distributed systems technologies, including Enterprise Services, System.Messaging, Microsoft .NET Remoting, ASMX, and WSE to deliver a unified development experience across multiple axes, including distance (cross-process, cross-machine, cross-subnet, cross-intranet, cross-Internet), topologies (farms, fire-walled, content-routed, dynamic), hosts (ASP.NET, EXE, Windows Presentation Foundation, Windows Forms, NT Service, COM+), protocols (TCP, HTTP, cross-process, custom), and security models (SAML, Kerberos, X509, username/password, custom).

  2. What is service and client in perspective of data communication?
    A service is a unit of functionality exposed to the world. The client of a service is merely the party consuming the service.

  3. What is endpoint in WCF? or What is three major points in WCF?
    Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service.

    In WCF the relationship between Address, Contract and Binding is called Endpoint. The Endpoint is the fusion of Address, Contract and Binding.

    1. Address : Specifies the location of the service which will be like http://Myserver/MyService.Clients will use this location to communicate with our service.

    2. Contract : Specifies the interface between client and the server.It's a simple interface with some attribute.

    3. Binding : Specifies how the two paries will communicate in term of transport and encoding and protocols.
  4. What is binding and how many types of bindings are there in WCF?
    A binding defines how an endpoint communicates to the world. A binding defines the transport (such as HTTP or TCP) and the encoding being used (such as text or binary).

    A binding can contain binding elements that specify details like the security mechanisms used to secure messages, or the message pattern used by an endpoint.

    WCF supports nine types of bindings.

    1. Basic binding :
      Offered by the BasicHttpBinding class, this is designed to expose a WCF service as a legacy ASMX web service, so that old clients can work with new services. When used by the client, this binding enables new WCF clients to work with old ASMX services.


    2. TCP binding :
      Offered by the NetTcpBinding class, this uses TCP for cross-machine communication on the intranet. It supports a variety of features, including reliability, transactions, and security, and is optimized for WCF-to-WCF communication. As a result, it requires both the client and the service to use WCF.

    3. Peer network binding :
      Offered by the NetPeerTcpBinding class, this uses peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcast messages to it.

    4. IPC binding :
      Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding.

    5. Web Service (WS) binding :
      Offered by the WSHttpBinding class, this uses HTTP or HTTPS for transport, and is designed to offer a variety of features such as reliability, transactions, and security over the Internet.

    6. Federated WS binding :
      Offered by the WSFederationHttpBinding class, this is a specialization of the WS binding, offering support for federated security.

    7. Duplex WS binding :
      Offered by the WSDualHttpBinding class, this is similar to the WS binding except it also supports bidirectional communication from the service to the client.

    8. MSMQ binding :
      Offered by the NetMsmqBinding class, this uses MSMQ for transport and is designed to offer support for disconnected queued calls.

    9. MSMQ integration binding :
      Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients.
  5. What is contracts in WCF?
    In WCF, all services expose contracts. The contract is a platform-neutral and standard way of describing what the service does.

    WCF defines four types of contracts.

    1. Service contracts : Describe which operations the client can perform on the service.

    2. Data contracts : Define which data types are passed to and from the service. WCF defines implicit contracts for built-in types such as int and string, but we can easily define explicit opt-in data contracts for custom types.

    3. Fault contracts : Define which errors are raised by the service, and how the service handles and propagates errors to its clients.

    4. Message contracts : Allow the service to interact directly with messages. Message contracts can be typed or untyped, and are useful in interoperability cases and when there is an existing message format we have to comply with.

Happy Interview!!!
Share
Labels: ,

Post a Comment