Differences over WCF, WebService and WebApi with Asp.net?

7

I will create a service to make my company's data available to a customer. But I am evaluating the creation of the services and I came across this technical doubt. I know there are differences between the 3, but I do not know exactly how to evaluate. Can anyone help?

    
asked by anonymous 25.02.2016 / 17:07

1 answer

9

Web Service

  • It is based on SOAP and returns the data by default in XML.
  • It supports HTTP protocol only.
  • It is not open source, but can be consumed by any client that understands xml.
  • Can be hosted only on IIS.
  • It has a lot of documentation and has easy integration with other .Net frameworks

WCF

  • It is also based on SOAP and returns the data in the XML standard.
  • It is the evolution of the web service (ASMX) and supports various protocols like TCP, HTTP, HTTPS, Pipes, MSMQ.
  • The main problem with WCF is its tedious and extensive configuration.
  • It is not open source, but can be consumed by any client that understands xml.
  • It can be hosted on IIS or using window service.

WCF Rest

  • To use WCF as a WCF Rest service you just need to enable the webHttpBinding.
  • It supports HTTP GET and POST by attributes [WebGet] and [WebInvoke] respectively.
  • To allow other HTTP verbs you have to make additional settings in IIS, which can be a bit costly.
  • Passing data through parameters using a WebGet UriTemplate must be specified and configured.
  • It supports XML, JSON and ATOM data format.

Api Web

  • This is the new framework for building HTTP services and has a proposal to be simpler and easier to use.
  • Web API is open source and designed to build REST-Ful services with the .NET Framework.
  • Unlike the WCF Rest service, it uses HTTP capabilities (such as URIs, request / response headers, cache, version control, various content formats)
  • It also supports MVC features such as routing, controllers, action results, filter, model binders, IOC container and also dependency injection,
  • It can be hosted as an application or in IIS.
  • An architecture considered "lightweight" and good for devices that have limited bandwidth, such as mobile devices.
  • Responses are formatted by the MediaTypeFormatter in JSON, XML, or whatever format you want to add as a MediaTypeFormatter.

Final considerations:

  • Choose WCF when you want to create a service that should support special scenarios such as messaging, message queues, duplex communication, etc.
  • Choose WCF when you want to create a service that can use fast transport channels when available, such as TCP, Pipes, or maybe even UDP (in WCF 4.5).
  • Choose Web API when you want to create a service over HTTP protocol like Post, Get or Put.
  • Choose Web API when you want to expose your service to a wide range of clients, including browsers, mobile phones, iphone, and tablets.
  • This is my opinion on which service to choose. Evaluate well your scenario, your resources and available time to create each project.

    Source: Simple Code

        
    25.02.2016 / 17:13