WCF Interview Flashcards
What is WCF?
WCF is a platform for building distributed businesses and deploying services among various endpoints in Windows. WCF was initially called “Indigo” and we can build service-oriented applications and provide interoperability.
WCF or Windows Communication Foundation is a programming model to create service oriented applications. It is used to create and deploy the service that is accessible to lots of different clients. It provides an environment where you can create a service which can be accessible to Windows clients as well as Linux clients or any others. It provides more features compared to web services.
WCF is a Microsoft technology to create service oriented application. Before the WCF, the Web Service was used to create services but that type of service is only accessible to Windows client hosted on HTTP protocol. But WCF services are accessible with different protocols like http, tcp, msmq, etc.
Explain WCF Architecture and also explain its Fundamentals?
Windows Communication Foundation (WCF) is a framework for building service-oriented applications by which we can send asynchronous message/data from one service endpoint to another service endpoint.
WCF is a runtime and a set of APIs for creating systems that sends messages between services and clients. The same infrastructure and APIs are used to create applications that communicate with other applications on the same computer system or on a system that resides in another company and is accessed over the Internet.
The WCF fundamentals are as follows:
- Unification
- COM+ Services
- Web Services
- .NET Remoting
- Microsoft Message Queuing
- Interoperability
- Service Orientation
Why Should We Use WCF Service?
Windows Communication Foundation (WCF) is a framework for building service-oriented applications.
Why WCF?
- A web service to exchange messages in XML format using HTTP protocol for interoperability.
- A remoting service to exchange messages in binary format using TCP protocol for performance.
What are the features and advantage of WCF?
Windows Communication Foundation (WCF) is a secure, reliable, and scalable messaging platform for the .NET Framework 3.0:
Service Orientation
Interoperability (COM+/COM/.NET Remoting/WS 3.0/ASP.NET Web Services)
Multiple Message Patterns (Request/Response, OneWay, Duplex)
Service Metadata
(The Windows Communication Foundation (WCF) provides an infrastructure for exporting, publishing, retrieving, and importing service metadata. WCF services use metadata to describe how to interact with the service’s endpoints so that tools, such as Svcutil.exe, can automatically generate client code for accessing the service.)
Data Contracts
Security
Multiple Transports and Encodings
Reliable and Queued Messages
Durable Messages
Transactions
AJAX and REST Support
Extensibility
Advantages of WCF:
Service Oriented
Location Independent
Language Independent
Platform Independent
Support Multiple operation
WCF can maintain transaction like COM+ Does
It can maintain state
It can control concurrency
It can be hosted on IIS, WAS, Self hosting, Windows services.
It has AJAX Integration and JSON (JavaScript object notation) support.
WCF can be configured to work independently of SOAP and use RSS instead.
WCF is one of the fastest communication technologies and offers excellent performance compared to other Microsoft specifications.
To improve communication, transmission speed needs to be optimized. This is done by transmitting binary-coded XML data instead of plain text to decrease latency.
Object life-cycle management and distributed transaction management are applicable to any application developed using WCF.
What Is Binding In WCF?
Binding
- describes how a service communicates
- specifies which protocol to be used
- specifies the encoding method to format the message context
- specifies the security requirements
- specifies the message exchange format
- specifies message session mode
- developer could create custom Binding also
What was the difference between WSDL & Mex Endpoint in WCF?
What is the difference between WCF and Web services?
Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another.
Web Services: A Web Service is programmable application logic accessible via standard web protocols. One of these web protocols is the Simple Object Access Protocol (SOAP). SOAP is a W3C submitted note (as of May 2000) that uses standards based technologies (XML for data description and HTTP for transport) to encode and transmit application data.
What replaces WCF in .Net Core?
Explain what is SOA?
SOA stands for service oriented architecture. Service Oriented Architecture is an architectural approach in software development where the application is organized as “Services”. Services are a group of methods that contain the business logic to connect a DB or other services. For instance you go to a hotel and order food. Your order first goes to the counter and then it goes to the kitchen where the food is prepared and finally the waiter serves the food.
SOA Overview: A Service Oriented Architecture is based on four key abstractions.
An Application Front End
A Service
A Service Repository
A Service Bus
Application Front End: The application front end is decoupled from the services. Each service has a contract that defines what it will do and one or more interfaces to implement the contract.
A Service: It has the methods with the defined contracts and the implementation of the business logic to connect the DB or other service.
A Service Repository: The service repository provides a home for the services and the service bus provides an industry-standard mechanism for connecting to and interacting with the services.
What is Service Contract in WCF?
Service contract means the collective mechanisms by which a service’s capabilities and requirements are specified for its consumers. We must say that it defines the operations that a service will perform when executed. It tells more things about a service, like message data types, operation locations, the protocols the client will need in order to communicate with the service.
To create a service contract you define an interface with related methods representative of a collection of service operations, and then decorate the interface/class with the ServiceContract Attribute to indicate it is a service contract. Methods in the interface that should be included in the service contract are decorated with the OperationContract Attribute.
Are web-services SOA?
SOA is thinking, it’s an architectural concept and web service is one of the technical approach to complete it. Web services are the preferred standards to achieve SOA.
In SOA we need the services to be loosely coupled. A web service communicates using SOAP protocol which is XML based which is very loosely coupled. SOA services should be able to describe themselves. WSDL describes how we can access the service.
SOA services are located in a directory. UDDI describes where we can get the web service. This nothing but implementation of SOA registry.
What are Contracts in WCF? How many Contracts are in WPF?
The main use of contracts is to allow the client and services agree as to the types of operations and structures they will use during the communication process. It also shows the formal agreements between client and service to define a platform-neutral and standard for describing that what the service does.
Service Contract:
A service contract defines the operations which are exposed by the service to the outside world. A service contract is the interface of the WCF service and it tells the outside world what the service can do. It may have service-level settings, such as the name of the service and namespace for the service.
Operation Contract:
An Operation Contract defines the method exposed to the client to exchange the information between the client and server. An Operation Contract describes what functionality is to be given to the client, such as addition, subtraction and so on.
Data Contract:
Data Contracts define the data type for variables that are the same as get and set properties but the difference is that a Data Contract in WCF is used to serialize and deserialize the complex data. It defines how data types are serialized and deserialized. Using serialization, you can convert an object into a sequence of bytes that can be transmitted over a network. Using de-serialization, you reassemble an object from a sequence of bytes that you receive from a calling application.
Message Contract
When an operation contract required to pass a message as a parameter or return value as a message, the type of this message will be defined as message contract. A message contract defines the elements of the message (like as Message Header, Message Body), as well as the message-related settings, such as the level of message security.
Message contracts give you complete control over the content of the SOAP header, as well as the structure of the SOAP body.
Fault Contract
A fault contract defines errors raised by the service, and how the service handles and propagates errors to its clients. An operation contract can have zero or more fault contracts associated with it.
What is End Points and how many types of End points?
Endpoints provide the configuration required for the communication and create the complete WCF service application.
An Endpoint is a piece of information that tells WCF how to build the runtime communication channels to send and receive messages. An endpoint consists of the three things address, binding and contract.