zoukankan      html  css  js  c++  java
  • What is the difference between a web API and a web service?

    What is the difference between a web API and a web service?

    Answer1

    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.

    Answer2

    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 is light-weight architectured and good for devices which have limited bandwidth, like mobile devices.

    What are WSDL, SOAP and REST?

    https://www.w3.org/TR/wsdl.html

    WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate, however, the only bindings described in this document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST, and MIME.

    https://www.w3.org/TR/soap12/

    SOAP Version 1.2 is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. "Part 1: Messaging Framework" defines, using XML technologies, an extensible messaging framework containing a message construct that can be exchanged over a variety of underlying protocols.

    回答1

    A WSDL is an XML document that describes a web service. It actually stands for Web Services Description Language.

    SOAP is an XML-based protocol that lets you exchange info over a particular protocol (can be HTTP or SMTP, for example) between applications. It stands for Simple Object Access Protocol and uses XML for its messaging format to relay the information.

    REST is an architectural style of networked systems and stands for Representational State Transfer. It's not a standard itself, but does use standards such as HTTP, URL, XML, etc.  

    Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. In REST style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs). The resources are acted upon by using a set of simple, well-defined operations. it follows client/server architecture and is designed to use a stateless communication protocol,typically HTTP.

    回答2

    Example: In a simple terms if you have a web service of calculator.

    WSDL: WSDL tells about the functions that you can implement or exposed to the client. For example: add, delete, subtract and so on.

    SOAP: Where as using SOAP you actually perform actions like doDelete(), doSubtract(), doAdd(). So SOAP and WSDL are apples and oranges. We should not compare them. They both have their own different functionality.

    Why we use SOAP and WSDL: For platform independent data exchange.

    EDIT: In a normal day to day life example:

    WSDL: When we go to a restaurant we see the Menu Items, those are the WSDL's.

    Proxy Classes: Now after seeing the Menu Items we make up our Mind (Process our mind on what to order): So, basically we make Proxy classes based on WSDL Document.

    SOAP: Then when we actually order the food based on the Menu's: Meaning we use proxy classes to call upon the service methods which is done using SOAP. :)

  • 相关阅读:
    在TNSNAMES.ORA文件中配置本机装的oracle
    Eclipse编辑jsp、js文件时,经常出现卡死现象解决汇总
    ExtJs GridPanel 给表格行或者单元格自定义样式
    Ext.core.DomQuery Dom选择器
    JavaScript 常用方法
    ExtJs Ext.data.Model 学习笔记
    JavaScript 深入理解作用域链
    Spring 网路搜集的情报
    SpringMVC 之类型转换Converter详解转载
    SpringMVC @RequestMapping 用法详解之地址映射
  • 原文地址:https://www.cnblogs.com/chucklu/p/10276503.html
Copyright © 2011-2022 走看看