Difference between WCF and Web API and wcf rest and Web Service, differencewcf

Source: Internet
Author: User

Difference between WCF and Web API and wcf rest and Web Service, differencewcf

The. net framework has a number of technologies that allow you to create HTTP services such as Web Service, WCF and now Web API. there are a lot of articles over the internet which may describe to whom you shoshould use. now a days, you have a lot of choices to build HTTP services on. NET framework. in this article, I wowould like to share my opinion with you over Web Service, WCF and now Web API. for m Ore information about Web API refers What is Web API and why to use it ?.

Web Service
  1. It is based on SOAP and return data in XML form.

  2. It support only HTTP protocol.

  3. It is not open source but can be consumed by any client that understands xml.

  4. It can be hosted only on IIS.

WCF
  1. It is also based on SOAP and return data in XML form.

  2. It is the evolution of the web service (ASMX) and support varous protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ.

  3. The main issue with WCF is, its tedious and extensive configuration.

  4. It is not open source but can be consumed by any client that understands xml.

  5. It can be hosted with in the applicaion or on IIS or using window service.

WCF Rest
  1. To use WCF as WCF Rest service you have to enable webHttpBindings.

  2. It support http get and POST verbs by [WebGet] and [WebInvoke] attributes respectively.

  3. To enable other HTTP verbs you have to do some configuration in IIS to accept request of that FIG on. svc files

  4. Passing data through parameters using a WebGet needs configuration. The UriTemplate must be specified

  5. It support XML, JSON and ATOM data format.

Web API
  1. This is the new framework for building HTTP services with easy and simple way.

  2. Web API is open source an ideal platform for building REST-ful services over the. NET Framework.

  3. Unlike WCF Rest service, it use the full featues of HTTP (like URIs, request/response headers, caching, versioning, various content formats)

  4. It also supports the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection, unit testing that makes it more simple and robust.

  5. It can be hosted with in the application or on IIS.

  6. It is light weight architecture and good for devices which have limited bandwidth like smart phones.

  7. Responses are formatted by Web API's MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter.

To whom choose between WCF or WEB API
  1. Choose WCF when you want to create a service that shocould support special scenarios such as one way 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, Named Pipes, or maybe even UDP (in WCF 4.5 ), and you also want to support HTTP when all other transport channels are unavailable.

  3. Choose Web API when you want to create a resource-oriented services over HTTP that can use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats ).

  4. Choose Web API when you want to expose your service to a broad range of clients including browsers, mobiles, iphone and tablets.

What do you think?

I hope, you have got when to use WCF, Web API and Web Service. I wowould like to have feedback from my blog readers. your valuable feedback, question, or comments about this article are always welcome.


What is the difference between WCF and web service? Or what is the difference between wcf and web service?

Both WCF and WebService communicate based on the Soap Protocol (in fact, the soap protocol is also in xml format)

1. WCF
The Soa architecture on the Microsoft platform is used to build distributed and interactive applications
Unifies the development model of ASMX,. NET Remoting, and Enterprise Service.
Provides a single programming model for various applications
Configuration-driven protocol selection, message format, process allocation, and so on
It is not restricted to specific protocols, encoding formats, or host environments.
All options are configurable.
The wcf 'service is called by the client by exposing the endpoint to the client (by calling the proxy class)

2. WebService
The following key technologies and rules are used to build and use Web services:
1. XML: Standard Method for describing data.
2. SOAP: Simple Object Access Protocol.
3. WSDL: Web Service Description Language.
4. UDDI (Universal Description, Discovery and Integration): Universal Description, Discovery, and Integration. It is a platform-independent, XML-based protocol used to describe commerce on the Internet.

Item 1: Cross-firewall communication
Item 2: Application Integration
Item 3: B2B Integration
Item 4: software and data Reuse
Weakness 1: stand-alone applications
Article 2: homogeneous LAN applications

WEB APIs are different from web mvc APIs.

WebAPI is added to the new MVC to provide a REST-style WebService. The new WebAPI project is the same as the typical MVC project, including the main Models, Views, Controllers and other folders and Global. asax file. Views is not very useful for webapis. The Model in Models is mainly used to save the objects for interaction between the Service and the Client. By default, these objects are converted to Json format for data transmission in two rows, the Controller in Controllers is a Resource corresponding to WebService and is used to provide services. Like common MVC, Global. asax is used to configure routing rules.
For a WebAPI, ingress is initially designed as the same as that of the WCF producer client and server. Currently, the ingress we haven't mentioned yet because our request is encapsulated the HTTP request rule is used to receive responses such as AJAX and Form submission.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.