locked
Why some one would learn web api RRS feed

  • Question

  • User264732274 posted

    client call web api and web api return data in json format, or xml format etc. but people can develop asmx service which can return data in json format and same wcf also can return data in json format too then why web api?

    people say web api is http service........what does it means ?

    asmx or wcf do not support http ?

    guide me. thanks

    Tuesday, March 1, 2016 5:55 PM

Answers

  • User753101303 posted

    Hi,

    Yes there is some overlap. See https://msdn.microsoft.com/en-us/library/jj823172(v=vs.110).aspx for a WCF/web API comparison. Web API is more direct and more consistent with the MVC model (based on routing, controllers and actions; it even merged in ASP.NET Core 1.0).

    If you are using WCF and ASMX and that it fit your needs, no problem. For new projects it's likely best:
    - if this is a particular purpose you can consider using MVC (for example an autocomplete service used just from a particular view)
    - if this is really an API, web API
    - if you need its unique feature (non HTTP for example, web api is http *only*) then WCF (that does as well what ASMX does).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 1, 2016 6:15 PM
  • User-782957977 posted

    Web Api is rest based and useful if service is consumed  by JavaScript / Mobile clients. Any application can consume Web Api with Http requests without any configuration. Web Api is light weight compared to WCF rest service and can use all Http features.

    WCF / Asmx Web service is based on Soap. Usually Soap messages are complex and it will be difficult for JavaScript / Mobile clients to consume soap service. If client applications can consume soap service, then you can go with WCF service. You can take decision based on who is consuming the service and service security requirements.

    http://www.codeproject.com/Articles/341414/WCF-or-ASP-NET-Web-APIs-My-two-cents-on-the-subjec

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 2, 2016 4:09 AM
  • User36583972 posted

    Hi sudip_inn,

    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).

    It also supports MVC features, like routing, controller, action, filter, model binding, Inversion of Control (IOC) or dependency injection (DI), unit testing. These can make the program simpler, more robust.

    Web API is a lightweight frame and restrictions on bandwidth devices, such as smart phones and other supported well. Web API Response can be converted into the MediaTypeFormatter Json, XML or any format you want to convert. And it is uniquely suited to the mobile client service.

    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.

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 2, 2016 4:52 AM
  • User36583972 posted

    Hi sudip_inn,

    what do u mean by "restrictions on bandwidth devices" ??

    As far as I know, when we use some of the equipment, It can only accept relatively limited data at the same time. Web API is a lightweight architecture and good for these devices.

    If your client is a mobile device, the traffic issues is that everyone should pay attention to the problem of mobile applications.

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 2, 2016 9:22 AM
  • User-782957977 posted

    Representational State Transfer (REST) is an architectural style with following features

    URI - Each resource can be accessed with a unique uri
    Representations - Resources can be represented by formats like JSON, XML, Text etc
    Uniform interface - Resources can be manipulated using GET, POST, PUT And Delete methods


    http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 3, 2016 1:59 AM

All replies

  • User753101303 posted

    Hi,

    Yes there is some overlap. See https://msdn.microsoft.com/en-us/library/jj823172(v=vs.110).aspx for a WCF/web API comparison. Web API is more direct and more consistent with the MVC model (based on routing, controllers and actions; it even merged in ASP.NET Core 1.0).

    If you are using WCF and ASMX and that it fit your needs, no problem. For new projects it's likely best:
    - if this is a particular purpose you can consider using MVC (for example an autocomplete service used just from a particular view)
    - if this is really an API, web API
    - if you need its unique feature (non HTTP for example, web api is http *only*) then WCF (that does as well what ASMX does).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 1, 2016 6:15 PM
  • User264732274 posted

    do not understand this point.........if you need its unique feature (non HTTP for example, web api is http *only*) then WCF (that does as well what ASMX does).

    Tuesday, March 1, 2016 6:20 PM
  • User-782957977 posted

    Web Api is rest based and useful if service is consumed  by JavaScript / Mobile clients. Any application can consume Web Api with Http requests without any configuration. Web Api is light weight compared to WCF rest service and can use all Http features.

    WCF / Asmx Web service is based on Soap. Usually Soap messages are complex and it will be difficult for JavaScript / Mobile clients to consume soap service. If client applications can consume soap service, then you can go with WCF service. You can take decision based on who is consuming the service and service security requirements.

    http://www.codeproject.com/Articles/341414/WCF-or-ASP-NET-Web-APIs-My-two-cents-on-the-subjec

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 2, 2016 4:09 AM
  • User36583972 posted

    Hi sudip_inn,

    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).

    It also supports MVC features, like routing, controller, action, filter, model binding, Inversion of Control (IOC) or dependency injection (DI), unit testing. These can make the program simpler, more robust.

    Web API is a lightweight frame and restrictions on bandwidth devices, such as smart phones and other supported well. Web API Response can be converted into the MediaTypeFormatter Json, XML or any format you want to convert. And it is uniquely suited to the mobile client service.

    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.

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 2, 2016 4:52 AM
  • User264732274 posted

    @santhoshje : what do u mean "Web Api is rest based " ?

    just come with some example to explain the meaning of rest based. thanks

    Wednesday, March 2, 2016 7:51 AM
  • User264732274 posted

    @Yohann Lu what do u mean by "restrictions on bandwidth devices" ??

    please explain what u try to say. thanks

    Wednesday, March 2, 2016 7:53 AM
  • User36583972 posted

    Hi sudip_inn,

    what do u mean by "restrictions on bandwidth devices" ??

    As far as I know, when we use some of the equipment, It can only accept relatively limited data at the same time. Web API is a lightweight architecture and good for these devices.

    If your client is a mobile device, the traffic issues is that everyone should pay attention to the problem of mobile applications.

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 2, 2016 9:22 AM
  • User-782957977 posted

    Representational State Transfer (REST) is an architectural style with following features

    URI - Each resource can be accessed with a unique uri
    Representations - Resources can be represented by formats like JSON, XML, Text etc
    Uniform interface - Resources can be manipulated using GET, POST, PUT And Delete methods


    http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 3, 2016 1:59 AM
  • User187148431 posted

    hi

    for web api go through the following link:-

    http://tutorial.techaltum.com/web-api.html

    Saturday, March 19, 2016 11:54 AM