locked
When to use WebAPI? RRS feed

  • Question

  • User246057125 posted

    I am developing MVC 5 application and interested to implement WebAPI.

    I am not following under which scenario to use Web API. 

    Is it only suitable to communicate with other applications with a method other than SOAP?

    Friday, February 12, 2016 7:20 AM

Answers

  • User36583972 posted

    Hi rpk2006,  

    Web API is the great framework for exposing your data and service to different-different devices. Unlike WCF Rest service, it use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats) and you don't need to define any extra config settings for different devices.  

    You can consider using the Web API when you encounter the following situations.

    1. If we need a Web Service and don’t need SOAP, then ASP.Net Web API is best choice.
    2. It is Used to build simple, non-SOAP-based HTTP Services on top of existing WCF message pipeline.
    3. It doesn't have tedious and extensive configuration like WCF REST service.
    4. Simple service creation with Web API. With WCF REST Services, service creation is difficult.
    5. It is only based on HTTP and easy to define, expose and consume in a REST-ful way.
    6. It is light weight architecture and good for devices which have limited bandwidth like smart phones.
    7. It is open source.

    The following tutorial describes the major features of the API and WCF technology:

    https://msdn.microsoft.com/en-us/library/jj823172(v=vs.110).aspx

    Best Regards,  

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 12, 2016 7:57 AM

All replies

  • User541108374 posted

    Hi,

    Is it only suitable to communicate with other applications with a method other than SOAP?

    No, quite some people make use of it by calling it from ajax for example. If you follow a bit the new ASP.NET Core path you'll notice that MVC and Web API have one common Controller class they inherit from so basically these twins have been merged into one.

    Grz, Kris.

    Friday, February 12, 2016 7:32 AM
  • User36583972 posted

    Hi rpk2006,  

    Web API is the great framework for exposing your data and service to different-different devices. Unlike WCF Rest service, it use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats) and you don't need to define any extra config settings for different devices.  

    You can consider using the Web API when you encounter the following situations.

    1. If we need a Web Service and don’t need SOAP, then ASP.Net Web API is best choice.
    2. It is Used to build simple, non-SOAP-based HTTP Services on top of existing WCF message pipeline.
    3. It doesn't have tedious and extensive configuration like WCF REST service.
    4. Simple service creation with Web API. With WCF REST Services, service creation is difficult.
    5. It is only based on HTTP and easy to define, expose and consume in a REST-ful way.
    6. It is light weight architecture and good for devices which have limited bandwidth like smart phones.
    7. It is open source.

    The following tutorial describes the major features of the API and WCF technology:

    https://msdn.microsoft.com/en-us/library/jj823172(v=vs.110).aspx

    Best Regards,  

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 12, 2016 7:57 AM
  • User-1877975950 posted

    You might want to consider OData, which is pretty much covered here:

    http://stackoverflow.com/questions/2458407/difference-between-odata-and-rest-web-services

    Friday, February 12, 2016 9:10 AM
  • User1035898639 posted

    Hi,

    The detailed informations can be found here: http://www.dotnet-tricks.com/Tutorial/webapi/VG9K040413-What-is-Web-API-and-why-to-use-it-?.html

    Tuesday, February 16, 2016 5:48 AM