ASP.net Web API Series--Select the Web API or Wcf__.net

Source: Internet
Author: User
Tags soap

Http://www.nmtree.net/2014/10/19/asp-net-web-api-series-choosing-asp-net-web-api-or-wcf.html

WCF is a one-stop framework for. NET Platform Services Development, so why should there be a asp.net Web api? Simply put, the ASP.net Web API was designed and built with one thing in mind: HTTP, and WCF was designed primarily to consider soap and ws-*.

WCF has been around for years and, relatively speaking, the ASP.net Web API is a little child, but it does not mean that the ASP.net Web API is a substitute for WCF and that they have strengths on different occasions. The ASP.net Web API is very lightweight and cannot be compared to WCF in functionality and flexibility. If your service is based on TCP, or if you support more transport mechanisms, WCF is the best option. However, not all platforms support soap and ws-*, and the ASP.net Web API is even better when the client does not support these protocols.

Let's take a look at the difference between the two programming models: a service that gets employees of a company based on an employee ID. WCF code such as 1-1,asp.net Web API code like 1-2

1-1 WCF way to get employee information

[Serviceco"] Ntract] public interface Iemployeeservice {     [OperationContract]      [ WebGet (UriTemplate =  "/employees/{id}")]      Employee getemployee (string id); public class Employeeservice:iemployeeservice {     public Employee GetEmployee (string id)   ;    {         return
1 2 3 4 5 6 7 8 (9) "
Related Article

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.