WCF vs WEb api vs Web Services for the New E-Commerce Site

I am creating a new e-commerce application in MVC and sql server as a database. I want to use the Entity framework for this. I am confused about choosing a data access level. Which one should be used between WCF and Web api vs Web services. Perhaps in the future we may need an Android and iOS app. I think Web api would be the best option for this.

I am trying to find the difference between web api and WCF that I found. The new ASP.NET web API is a continuation of the previous WCF web API project (although some of the concepts have changed).

WCF was created to enable SOAP-based services. For simpler RESTful or RPCish services (such as jQuery, for example), the ASP.NET Web API should be a good choice. There are thousands of links telling about Rest, TCP, FTP, soap, Http. But no, where did I find my answer. I am still confused which one will fulfill my problem. Another thing, if I choose Web api, can integrate entity structure with Web api. I am new to point network. any help would be very helpful.

Edit: @win thanks for the help. I want to know how to decide which one to choose, RESTFull (Web api) or WCF (Soap). What factors in the application decide which one to use.

+5
source share
1 answer

WCF provides a lot of functionality, but at the cost of insane configuration settings. Crazy. It includes the definition of "ABC", "Address, Binding", "Contract". I always tell people "with WCF: its configuration, not the code." There are only ~ so many options to configure it.

If you need to push / pull small amounts of data into the "clients" (browser, android, iphone), then WebApi will be the best option.

One of the functions, WebApi will provide you with xml OR json how to configure the request (in the header).

With WCF, you need to β€œencode” either / or / both for json and xml, and this is not super trivial. Aka, you have to put the attributes in Service-Methods ("Contract" ABC) to say "this method will send xml back" or "this method will send json back".

Your WebApi level will provide services. This usually means providing json data or using json data. And MS took care of the "plumbing" for you, so that on the part of the services, this happens automatically-magically.

I coded both from 2005 (well, WCF in 2005 onwards, and then later with WebApi).

WebApi is much easier to handle, especially for beginners.

Therefore, if you have no specific reason to use WCF, I would use WebApi.

As for ORM, this happens entirely on the server side, so you can choose the one you want. I would choose Poco / Code-First / Entity-Framework or NHibernate.

Below is a small explanation of the motorway ... where you don't parse json on the SERVER side.

http://encosia.com/using-jquery-to-post-frombody-parameters-to-web-api/

and here

http://encosia.com/rest-vs-rpc-in-asp-net-web-api-who-cares-it-does-both/

Beyond my opinion here, here is a Microsoft comparative article:

https://msdn.microsoft.com/en-us/library/jj823172.aspx

and quote:

Use WCF to create reliable and secure web services available for different modes of transport. Use the ASP.NET Web API to create HTTP-based services available from a wide range of clients. Use the ASP.NET Web API if you are creating and developing new services such as REST. Although WCF provides some support for writing services such as REST, the REST support in the ASP.NET Web API is more complete, and all future REST improvements will be made in the ASP.NET Web API. If you have an existing WCF service and want to open additional REST endpoints, use WCF and WebHttpBinding.

+6
source

Source: https://habr.com/ru/post/1243668/


All Articles