WCF vs WEb api vs Web services for new ecommerce website

This question already has an answer here:

  • WCF vs ASP.NET Web API [closed] 10 answers

  • WCF provides a lot of functionality, but at the cost of crazy-mad configuration setup. Crazy mad. It involves defining an "ABC", Address, Binding, Contract. I always tell people "with WCF: its the configuration, not the code". There are just ~so many options for configuring it.

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

    One feature, WebApi will give you xml OR json via how the request is setup (in the 'header').

    With WCF, you have to "code up" either/or/both for json and xml and it isn't super trivial. Aka, you have to put attributes on the Service-Methods (the "Contract" of the ABC) to say "this method will send back xml" or "this method will send back json".

    Your WebApi layer will provides services. This usually means providing json data or consuming json data. And MS has taken care of the "plumbing" for you, so on the services side, this happens auto-magically.

    I've coded both since 2005 (well, WCF in 2005 and following, and then later with WebApi).

    WebApi is much easier to deal with, especially for a beginner.

    So unless you have a very concrete reason to use WCF, I would use WebApi.

    As far as an ORM, that happens completely on the "server side", so you can pick whichever one you want. I would pick Poco/Code-First/Entity-Framework OR NHibernate.

    Here is a little explanation of the auto-magic wire up...where you are not hand-parsing 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/

    Outside of my opinions here, here is a Microsoft comparison article :

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

    and the quote:

    Use WCF to create reliable, secure web services that accessible over a variety of transports. Use ASP.NET Web API to create HTTP-based services that are accessible from a wide variety of clients. Use ASP.NET Web API if you are creating and designing new REST-style services. Although WCF provides some support for writing REST-style services, the support for REST in ASP.NET Web API is more complete and all future REST feature improvements will be made in ASP.NET Web API. If you have an existing WCF service and you want to expose additional REST endpoints, use WCF and the WebHttpBinding.

    链接地址: http://www.djcxy.com/p/71476.html

    上一篇: 为什么要编写RESTful API,如果他们应该使用HATEOAS?

    下一篇: WCF vs WEb api vs新的电子商务网站的Web服务