Is there any difference between a web API and a web service ? Or are they one and the same ?

有帮助吗?

解决方案

A web service typically offers a WSDL from which you can create client stubs automatically. Web Services are based on the SOAP protocol. ASP.NET Web API is a newer Microsoft framework which helps you to build REST based interfaces. The response can be either JSON or XML, but there is no way to generate clients automatically because Web API does not offer a service description like the WSDL from Web Services. So it depends on your requirements which one of the techniques you want to use. Perhaps even WCF fits your requirements better, just look at the MSDN documentation.

其他提示

The basic difference between Web Services and Web APIs

Web Service:

1) It is a SOAP-based service and returns data as XML.

2) It only supports the HTTP protocol.

3) It is not open source but can be used by any client that understands XML.

5) It requires a SOAP protocol to receive and send data over the network, so it is not a light-weight architecture.

Web API:

1) A Web API is an HTTP based service and returns JSON or XML data by default.

2) It supports the HTTP protocol.

3) It can be hosted within an application or IIS.

4) It is open source and it can be used by any client that understands JSON or XML.

5) It has light-weight architecture and good for devices which have limited bandwidth, like mobile devices.

API vs Web Service

Just pasted the summary of the linked article:

Summary:

  1. All Web services are APIs but all APIs are not Web services.

  2. Web services might not perform all the operations that an API would perform.

  3. A Web service uses only three styles of use: SOAP, REST and XML-RPC for communication whereas API may use any style for communication.

  4. A Web service always needs a network for its operation whereas an API doesn’t need a network for its operation.

  5. An API facilitates interfacing directly with an application whereas a Web service is a ...

Read more: Difference Between API and Web Service | Difference Between | API vs Web Service http://www.differencebetween.net/technology/internet/difference-between-api-and-web-service/#ixzz3e3WxplAv

See the above link for the complete answer.

for more detail visit this link Diagram

A Web Service if you want is a Web API. Specifically Web API usually means RESTful (HTTP based) web service and Web Service usually means SOAP+WSDL (+HTTP or SMTP or JMS..).

Tipically RESTful web services are opposed to Web Services (WSDL,SOAP) but recently it has been introduced the term RESTful Web services (with uppercase 'W') that means RESTful+WSDL+SOAP..

Check out this chart for differences among the three concepts: http://www2.mokabyte.it/cms/figureproviderservlet?figureId=IUS-6NS-OBV_7f000001_19624184_5621ef4e--Fig02.jpg

Hope it helps!

Web service is absolutely the same as Web API - just a bit more restricted in terms of underlying data format. Both use HTTP protocol and both allows to create RESTful services. And don't forget for other protocols like JSON-RPC - maybe they fit better.

API and Web service serve as a means of communication.

The only difference is that a Web service facilitates interaction between two machines over a network. An API acts as an interface between two different applications so that they can communicate with each other. An API is a method by which third-party vendors can write programs that interface easily with other programs. A Web service is designed to have an interface that is depicted in a machine-processable format usually specified in Web Service Description Language (WSDL)

All Web services are APIs but not all APIs are Web services.

A Web service is merely an API wrapped in HTTP.


This here article provides good knowledge regarding web service and API.

  1. Web service is a collection of open source protocols and standards used for exchanging data between systems or applications whereas API is a software interface that allows two applications to interact with each other without any user involvement.
  2. Web service is used for REST, SOAP and XML-RPC for communication while API is used for any style of communication.
  3. Web service supports only HTTP protocol whereas API supports HTTP/HTTPS protocol.
  4. Web service supports XML while API supports XML and JSON.
  5. All Web services are APIs but all APIs are not web services.

In the context of ASP.Net a Web API is a Controller whose base class is ApiController and does not use Views. A Web Service is a class derived from WebService and has automatic WSDL generation. By default it is a SOAP api, but you can also use JSON by adding a ScriptServiceAttribute.

Well, TMK may be right in the Microsoft world, but in world of all software including Java/Python/etc, I believe that there is no difference. They're the same thing.

Difference between Web Service and Web API nicely explained here:

https://softwareengineering.stackexchange.com/questions/38691/difference-between-web-api-and-web-service

Text from the link:

Web Services - that's standard defined by W3C, so they can be accessed semi-automatically or automatically (WSDL / UDDI). The whole thing is based on XML, so anyone can call it. And every aspect of the service is very well defined. There's parameters description standard, parameter passing standard, response standard, discovery standard, etc. etc. You could probably write 2000 pages book that'd describe the standard. There are even some "additional" standards for doing "standard" things, like authentication.

Despite the fact that automatic invoking and discovery is barely working because clients are rather poor, and you have no real guarantee that any service can be called from any client.

Web API is typically done as HTTP/REST, nothing is defined, output can be for eg. JSON/XML, input can be XML/JSON/or plain data. There are no standards for anything => no automatic calling and discovery. You can provide some description in text file or PDF, you can return the data in Windows-1250 instead of unicode, etc. For describing the standard it'd be 2 pages brochure with some simple info and you'll define everything else.

Web is switching towards Web API / REST. Web Services are really no better than Web API. Very complicated to develop and they eat much more resources (bandwidth and RAM)... and because of all data conversions (REQUEST->XML->DATA->RESPONSE->XML->VALIDATION->CONVERSION->DATA) are very slow.

Eg. In WebAPI you can pack the data, send it compressed and un-compress+un-pack on the client. In SOAP you could only compress HTML request.

All WebServices is API but all API is not WebServices, API which is exposed on Web is called web services.

Two things are very simple to understand,

  1. API: It's an layer on application which can serve other application request locally.
  2. Webs Service:Is an API which can serve request and respond over the network form remote system over the web or internet .

Note: All Web Service is API's but not all API' is web services

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top