Differences about WCF, Webservice and Webapi with Asp.net?

Asked

Viewed 2,836 times

7

I will create a service to make my company’s data available to a client. But I am evaluating the creation of the services and I came across this technical doubt. I know there are differences between the three, but I don’t know exactly how to assess them. Anyone can help?

1 answer

10


Web Service

  • It is based on SOAP and returns the data by default in XML.
  • It only supports HTTP protocol.
  • It is not open source, but can be consumed by any client that understands xml.
  • Can only be hosted on IIS.
  • It has plenty of documentation and easy integration with other . Net-based 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 just enable webHttpBinding.
  • It supports HTTP GET and POST by [Webget] and [Webinvoke] attributes 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.

Web Api

  • This is the newest framework for building HTTP services and has a proposal to be simpler and easier to use.
  • Web API is open source and designed for building REST-Ful services with the . NET Framework.
  • Unlike the WCF Rest service, it uses HTTP features (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 on IIS.
  • It is an architecture considered "lightweight" and good for devices that bandwidth is limited, such as mobile devices for example.
  • Responses are formatted by Mediatypeformatter in JSON, XML or any format you want to add as a Mediatypeformatter.

Final considerations:

  1. Choose WCF when you want to create a service that should support special scenarios such as messaging, message queues, duplex communication etc.
  2. 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).
  3. Choose Web API when you want to create a service over HTTP protocol like Post , Get or Put.
  4. Choose Web API when you want to expose your service to a wide range of customers including browsers, mobiles, iphone and tablets.

This is my opinion on which service to choose. Assess your scenario, your resources and the time available to create each project.

Source: Codis

  • @Marconciliosouza, in the research source.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.