Comparison of Web APIs and WCF

Source: Internet
Author: User
Tags representational state transfer

There are many technologies available that allow you to create services that are consumed by different clients, such as Web applications, Windows applications, mobile apps, and so on. The service can support HTTP protocols or other protocols. The next discussion is limited to the ASP. NET Web API and WCF.

WCF (Windows communication Foundation), using WCF you can build secure and reliable services, and achieve cross-platform inheritance and smooth interaction.

Web API, a framework for building HTTP services. Now that we're using mobile phones, tablets, apps, and a variety of different types of services every day, the Web API is a simple and reliable platform that you can use to build HTTP services that serve a wide range of clients. Using the Web API you can create a complete rest service.

Soap

SOAP (Simple Object Access Protocol) is a protocol proposed by Microsoft to create structured data or messages that are transmitted over the Internet. SOAP is the primary foundation for using WCF and XML formats. Web Service builds a WSDL (Web Services Description Language) file that provides information about the service data. The WSDL file is used by the client to understand the methods available in the service.

REST

REST (representational state Transfer) is not a protocol like soap. It is an architectural design pattern used to build Web services. The Web API uses this pattern to build Web services. Fundamentally, the Web API is a resource-driven architecture that exposes the client to a service endpoint. The Web API supports the complete rest style, which uses GET, PUT, POST, delete to communicate with the client.

Interactivity

RESTful services, such as Web APIs, are characterized by simple, lightweight, HTTP-enabled requests, and are easy for clients to obtain. Unlike soap, it requires the client to understand the WSDL to implement the service. WSDL uses additional configuration and requirements for additional logic, which may not be convenient for many devices such as mobile phones, smart TVs, tablets, and so on. Because WCF supports multiple protocols, it can be consumed by many clients that use different protocols (HTTP, TCP, MSMQ, and so on).

Configuration Management

With respect to the Web API, clients need to use more configuration to get WCF services. WCF uses more configuration items (such as endpoints, behaviors, and so on) to expose the service. However, the Web API has more specifications to customize services for clients.

Speed

Because RESTful services use HTTP protocols and HTTP requests/responses that are lighter than soap, Web APIs are the best choice if you plan to build services for low-traffic devices or mobile phones. The request/response is more readable than soap,http because soap contains more complex elements such as header, body, and so on.

Safety

WCF provides an enterprise-class level of security that uses the WS-I standard to provide security services. Web APIs use web-standard security measures, such as Basic authentication, token validation, and more complex oauth,web APIs to appear more flexible. If you need to verify external services such as Google, Facebook, etc., then use SOAP.

To sum up, it seems difficult for us to decide which is better. But we can draw a two-point conclusion. One, if you need to build a service for different platforms, then use WCF, and if you need to build an Internet-based service, use the Web API.

WCF differs from Web API (scenario)

Differences between WCF, WebAPI, Wcfrest, WebService

Comparison of Web APIs and WCF

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.