I need your help in knowing the difference between ASP.NET Web API and WCF. From what I have been reading, it seems the Web API is a more lightweight version of WCF. Is that true Gurus? If I understand correctly, it is also used to directly connect from
the web server to the database, without any middle tier in between. Please correct me if I am wrong Gurus.
Is it possible to develop a full fledged SOA solution by utilizing the ASP.NET Web API? What are the limitations of this framework Gurus? And what are the typical scenarios in which it is advisable to go with the Web API rather than WCF? Enlighten me, O
Gurus!
In short, you can build services with either. Web API is HTTP focused, whereas WCF is SOAP focused. Web API, given its HTTP focus, allow for better/easier reach to different platforms (JavaScript, iOS, Android, etc), whereas WCF, given its SOAP nature has
some features that you might not get from the simpler Web API style (but to be honest, people rarely use those features), but at the expense of needing a heavier and more complicated framework.
The industry in general (meaning software beyond the Microsoft ecosystem) is leaning more towards Web API and SOAP is being used less and less.
Web API is just a way of writing REST web services that you host in IIS, whereas WCF is a whole communications framework. It can do REST if you want, but it can also do non-REST, SOAP style webservices allowing data to be sent and received in a better defined
way, it allows clients to discover the methods and objects available etc, it also have support for various web protocols and also some non-standard ones, that allow for better control over security, protocols that support "sessioning" where server-side state
is maintained for the life of the client. WCF also doesn't have to be hosted in IIS, it can be hosted in IIS or in any process such as a desktop app, a windows service etc. WCF also supports a far wider range of transport mechanisms, not just http. It supports
binary transfer via TCP, it supports communication over MSMQ and so on. Web API can do a very very very small subset of what WCF can do, but if Web API does everything you need there is no reason not to use it. WCF can be quite complicated to setup and configure.
asp.netwebapi
I'm afraid I no longer use this forum due to the new point allocation system.
I just had one more question - is the Web API used for direct communication between the web and database tiers? Does it do away with the middle tier that is typically hosted on an application server? Or can we use the Web API too to create something like
a WCF facade?
But if the Web API does away with the middle tier, where would you put your business logic? On the web server itself? Doesn't that cause a paradigm shift in the architecture? And wouldn't putting the business logic on the web server come with its own security
concerns?
But can Web API be used the same way as WCF, to create a facade for the business logic on the application server, which is then accessed by the web pages through the proxy classes? Please let me know Guru BrockAllen, many thanks once again!
But if the Web API does away with the middle tier, where would you put your business logic? On the web server itself? Doesn't that cause a paradigm shift in the architecture? And wouldn't putting the business logic on the web server come with its own security
concerns?
Novice Kid
Web API\WCF doesn't really "replace" a standard layer like a business layer, it just provides functionality via a service\web interface. It's up to you do define what role that service has. For example you might having a banking service that takes a card
number, and amount, and debits the card that amount. The calling code then just passes the info and the task is done. In that instance the web service would have a lot of business logic, such as working out what security features the card uses, validating
the information is correct, making decisions about when it isn't correct, making decisions about when 3DS is to be used and so on and so on....all that logic is hidden from the client. Or you might have a web service that is simply a way to select from and
update a data store like a database. So the calling code will do things like "GetPerson" and "UpdatePerson", and that service will have no business logic, but the code that calls the service does all of the business logic.
It's basically up to you do define where your logic sits and what roles your various layers are going to do.
asp.netwebapi
I'm afraid I no longer use this forum due to the new point allocation system.
Member
42 Points
102 Posts
Difference between ASP.NET Web API and WCF
Sep 08, 2014 01:56 PM|Novice Kid|LINK
Gurus!
I need your help in knowing the difference between ASP.NET Web API and WCF. From what I have been reading, it seems the Web API is a more lightweight version of WCF. Is that true Gurus? If I understand correctly, it is also used to directly connect from the web server to the database, without any middle tier in between. Please correct me if I am wrong Gurus.
Is it possible to develop a full fledged SOA solution by utilizing the ASP.NET Web API? What are the limitations of this framework Gurus? And what are the typical scenarios in which it is advisable to go with the Web API rather than WCF? Enlighten me, O Gurus!
Novice Kid
asp.netwebapi
All-Star
20376 Points
6505 Posts
ASPInsiders
MVP
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:04 PM|BrockAllen|LINK
In short, you can build services with either. Web API is HTTP focused, whereas WCF is SOAP focused. Web API, given its HTTP focus, allow for better/easier reach to different platforms (JavaScript, iOS, Android, etc), whereas WCF, given its SOAP nature has some features that you might not get from the simpler Web API style (but to be honest, people rarely use those features), but at the expense of needing a heavier and more complicated framework.
The industry in general (meaning software beyond the Microsoft ecosystem) is leaning more towards Web API and SOAP is being used less and less.
asp.netwebapi
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
All-Star
37441 Points
9076 Posts
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:06 PM|AidyF|LINK
Web API is just a way of writing REST web services that you host in IIS, whereas WCF is a whole communications framework. It can do REST if you want, but it can also do non-REST, SOAP style webservices allowing data to be sent and received in a better defined way, it allows clients to discover the methods and objects available etc, it also have support for various web protocols and also some non-standard ones, that allow for better control over security, protocols that support "sessioning" where server-side state is maintained for the life of the client. WCF also doesn't have to be hosted in IIS, it can be hosted in IIS or in any process such as a desktop app, a windows service etc. WCF also supports a far wider range of transport mechanisms, not just http. It supports binary transfer via TCP, it supports communication over MSMQ and so on. Web API can do a very very very small subset of what WCF can do, but if Web API does everything you need there is no reason not to use it. WCF can be quite complicated to setup and configure.
asp.netwebapi
All-Star
20376 Points
6505 Posts
ASPInsiders
MVP
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:09 PM|BrockAllen|LINK
Just as a side note: Web API is OWIN hostable, so it too can be hosted outside of IIS.
asp.netwebapi
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Member
42 Points
102 Posts
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:17 PM|Novice Kid|LINK
Thanks a lot Gurus AidyF and BrockAllen!
I just had one more question - is the Web API used for direct communication between the web and database tiers? Does it do away with the middle tier that is typically hosted on an application server? Or can we use the Web API too to create something like a WCF facade?
Seeking enlightenment Gurus!
Novice Kid
asp.netwebapi
All-Star
20376 Points
6505 Posts
ASPInsiders
MVP
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:22 PM|BrockAllen|LINK
Yes, Web API can be used to abstract DB access. Web APIs (given their HTTP nature) are about modeling access to resources.
asp.netwebapi
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Member
42 Points
102 Posts
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:29 PM|Novice Kid|LINK
Thanks again Guru BrockAllen!
But if the Web API does away with the middle tier, where would you put your business logic? On the web server itself? Doesn't that cause a paradigm shift in the architecture? And wouldn't putting the business logic on the web server come with its own security concerns?
Novice Kid
asp.netwebapi
All-Star
20376 Points
6505 Posts
ASPInsiders
MVP
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:35 PM|BrockAllen|LINK
I think of a Web API layer as a middle tier, so that's no different. And as always, logic could be either or both.
asp.netwebapi
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Member
42 Points
102 Posts
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:43 PM|Novice Kid|LINK
But can Web API be used the same way as WCF, to create a facade for the business logic on the application server, which is then accessed by the web pages through the proxy classes? Please let me know Guru BrockAllen, many thanks once again!
Novice Kid
asp.netwebapi
All-Star
20376 Points
6505 Posts
ASPInsiders
MVP
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 02:45 PM|BrockAllen|LINK
Yes.
asp.netwebapi
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
All-Star
37441 Points
9076 Posts
Re: Difference between ASP.NET Web API and WCF
Sep 08, 2014 03:23 PM|AidyF|LINK
Web API\WCF doesn't really "replace" a standard layer like a business layer, it just provides functionality via a service\web interface. It's up to you do define what role that service has. For example you might having a banking service that takes a card number, and amount, and debits the card that amount. The calling code then just passes the info and the task is done. In that instance the web service would have a lot of business logic, such as working out what security features the card uses, validating the information is correct, making decisions about when it isn't correct, making decisions about when 3DS is to be used and so on and so on....all that logic is hidden from the client. Or you might have a web service that is simply a way to select from and update a data store like a database. So the calling code will do things like "GetPerson" and "UpdatePerson", and that service will have no business logic, but the code that calls the service does all of the business logic.
It's basically up to you do define where your logic sits and what roles your various layers are going to do.
asp.netwebapi