What is a “web service” in plain English?

前端 未结 21 1041
半阙折子戏
半阙折子戏 2020-11-30 16:34

I\'ve been reading about \"web services\" here on SO, on Wikipedia, Google, etc., and I don\'t quite understand what they are. What is the plain English definition/descript

相关标签:
21条回答
  • 2020-11-30 17:05

    Yes that is a simple web service.

    Web services are really nothing more than a request/ response mechanism that allows a client to remotely access/ modify data. There are formal standards for web services (SOAP, SOA etc), but your simple page is a service too.

    The main downside to printing it to a page is that your service would return HTML. Preferable data formats are JSON and XML, because most client frameworks (and server frameworks) are designed around using JSON and XML.

    So if you modified your service to return:

    <RANDOM>some random number</RANDOM>
    

    rather than:

    <HEAD>...</HEAD>  
    <BODY>some random number</BODY>
    

    then it would be more useful to most clients

    0 讨论(0)
  • 2020-11-30 17:05

    In over simplified terms a web service is something that provides data as a service over the http protocol. Granted that isn't alway the case....but it is close.

    Standard Web Services use The SOAP protocol which defines the communication and structure of messages, and XML is the data format.

    Web services are designed to allow applications built using different technologies to communicate with each other without issues.

    Examples of web services are things like Weather.com providing weather information for that you can use on your site, or UPS providing a method to request shipping quotes or tracking of packages.

    Edit

    Changed wording in reference to SOAP, as it is not always SOAP as I mentioned, but wanted to make it more clear. The key is providing data as a service, not a UI element.

    0 讨论(0)
  • 2020-11-30 17:05

    A web service defines a contract of actions that a server will perform for you. The format and protocol doesn't really matter, but you should have some set definition of how the communication happens.

    In your example, it depends, if that is being used in another application that reads that number, yes it is service, otherwise, it's just a webpage with a number.

    0 讨论(0)
  • 2020-11-30 17:07

    For most sites you have HTML pages that you visit when you use your browser. These are human-readable pages (once rendered in your browser) where a lot of data might be crammed together, because it makes sense for humans.

    Now imagine that someone else want to use some of that data. They could download your page and start filtering out all the "noise" to get the data they wanted, but most websites are not built in a way where data is 100% certain to be placed in the same spot for all elements, so in addition to being cumbersome it also becomes unreliable.

    Enter web services.

    A web service is something that a website chooses to offer to those who wish to read, update and/or delete data from your website. You might call it a "backdoor" to your data. Instead of presenting the data as part of a webpage it is provided in a pre-determined way where some of the more popular are XML and JSON. There are several ways to communicate with a webservice, some use SOAP, others have REST'ful web services, etc.

    What is common for all web services is that they are the machine-readable equivelant to the webpages the site otherwise offers. This means that others who wish to use the data can send a request to get certain data back that is easy to parse and use. Some sites may require you to provide a username/password in the request, for sensitive data, while other sites allow anyone to extract whatever data they might need.

    0 讨论(0)
  • 2020-11-30 17:07

    A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Java and Python, or Windows and Linux applications) is due to the use of open standards (XML, SOAP, HTTP).

    All the standard Web Services works using following components:

    • SOAP (Simple Object Access Protocol)
    • UDDI (Universal Description, Discovery and Integration)
    • WSDL (Web Services Description Language)

    It works somewhat like this:

    • The client program bundles the account registration information into a SOAP message.
    • This SOAP message is sent to the Web Service as the body of an HTTP POST request.
    • The Web Service unpacks the SOAP request and converts it into a command that the application can understand.
    • The application processes the information as required and responds with a new unique account number for that customer.
    • Next, the Web Service packages up the response into another SOAP message, which it sends back to the client program in response to its HTTP request.
    • The client program unpacks the SOAP message to obtain the results of the account registration process.
    0 讨论(0)
  • 2020-11-30 17:08

    Simplified, non-technical explanation: A web serivce allows a PROGRAM to talk to a web page, instead of using your browser to open a web page.

    Example: I can go to maps.google.com, and type in my home address, and see a map of where I live in my browser.

    But what if you were writing a computer program where you wanted to take an address and show a pretty map, just like Google maps?

    Well, you could write a whole new mapping program from scratch, OR you could call a web service that Google maps provides, send it the address, and it will return a graphical map of the location, which you can display in your program.

    There is a lot more to it, as some of the other posts go into, but the upshot is that it allows your application to either retrieve information FROM, or submit information TO some resource. Some other examples:

    1. You can use a web service to retrieve information about books at Amazon.com
    2. You can use a similar web service to submit an order to Amazon.com
    3. You could CREATE a web service to allow outside applications to find out about product information within your company
    4. you could create a web service to allow outside applications to submit orders to your company.
    0 讨论(0)
提交回复
热议问题