Câu hỏi phỏng vấn API Design
Câu hỏi

Explain the difference between WCF,...

Câu trả lời

To answer the interview question "Explain the difference between WCF, Web API, WCF REST, and Web Service," it's important to understand the distinct features, use cases, and technical differences between these technologies. Here is a detailed explanation:

Web Service (ASMX)

  • Protocol: Web Services are based on the SOAP protocol and return data in XML format.
  • Transport: They support only the HTTP protocol.
  • Hosting: Web Services can only be hosted on IIS.
  • Interoperability: They are not open source but can be consumed by any client that understands XML.
  • Configuration: Web Services use the XmlSerializer for serialization.
  • Use Case: Suitable for simple, HTTP-based communication and legacy systems.

WCF (Windows Communication Foundation)

  • Protocol: WCF is a flexible framework that supports multiple protocols including HTTP, TCP, HTTPS, Named Pipes, and MSMQ.
  • Transport: It supports various transport protocols and can switch between them.
  • Hosting: WCF services can be hosted on IIS, WAS, self-hosting, or Windows services.
  • Interoperability: WCF is not open source but can be consumed by any client that understands XML.
  • Configuration: WCF uses extensive configuration settings and the DataContractSerializer for serialization.
  • Features: Supports advanced features like reliable messaging, transactions, message security, and duplex communication.
  • Use Case: Ideal for enterprise-level services requiring high security, reliability, and complex communication patterns.

WCF REST

  • Protocol: WCF REST is an extension of WCF to support RESTful services.
  • Transport: It primarily uses the HTTP protocol.
  • Configuration: Requires enabling webHttpBindings and using attributes like [WebGet] and [WebInvoke] for HTTP verbs.
  • Data Format: Supports XML, JSON, and ATOM formats.
  • Use Case: Suitable for scenarios where RESTful services are needed but within the WCF framework, often requiring additional configuration.

Web API

  • Protocol: Web API is designed for building RESTful services and supports the full features of HTTP.
  • Transport: It supports only the HTTP protocol.
  • Hosting: Web API can be hosted on IIS or self-hosted within an application.
  • Interoperability: Web API is open source and can be consumed by any client that supports HTTP.
  • Configuration: Uses the MVC features like routing, controllers, action results, and filters. It is lightweight and does not require extensive configuration.
  • Data Format: Supports various media types including JSON, XML, and custom formats via MediaTypeFormatter.
  • Use Case: Ideal for modern web, mobile, and cloud applications requiring lightweight, HTTP-based communication.

Summary Table

| Feature ...

expert

expert

Gợi ý câu hỏi phỏng vấn

junior

Answer the following interview API design question for me ""

junior

What is SOAP?

middle

What are disadvantages of REST web services?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào