什么是web服务_什么是Web服务?

2021-10-21 00:00:00 web 服务

什么是web服务

Web Services are client and server applications that communicate over the World Wide Web’s (WWW) Hypertext Transfer Protocol (HTTP). As described by the World Wide Web Consortium (W3C), web services provide a standard means of interoperating between software applications running on a variety of platforms and frameworks.

Web服务是通过万维网( WWW )超文本传输​​协议( HTTP )进行通信的客户端和服务器应用程序。 如万维网联盟(W3C)所述,Web服务提供了在各种平台和框架上运行的软件应用程序之间进行互操作的标准方法。

Web Services can be looked as a code on demand. Just like we call functions and methods, web services can be looked upon as calling a function or method over the internet using some sort of protocols and some agreements.

Web服务可以看作是按需代码 。 就像我们调用函数和方法一样,Web服务可以看作是使用某种协议和某些协议通过Internet调用函数或方法。

A web service is a function or method which we can call by sending an HTTP request to a URL, with arguments and the service returns the result back as response.

Web服务是一种函数或方法,可以通过将HTTP请求发送到带有参数的URL来调用该函数或方法,然后该服务将结果作为响应返回。

The biggest advantage of the web services is that it is platform independent.

Web服务的最大优点是它与平台无关。

《什么是web服务_什么是Web服务?》

Consider the above figure, We can see that the application written in Java can interact with PHP and .net platforms through the web service. Therefore, it is completely platform independent. A web service exposed in the PHP can be consumed by any platform be it java, .net or PHP. This capability of the web service is making it so popular. Therefore, a web service is a language independent way of communication.

考虑上图,我们可以看到用Java编写的应用程序可以通过Web服务与PHP和.net平台进行交互。 因此,它是完全独立于平台的。 PHP公开的Web服务可以被任何平台使用,无论是Java,.net还是PHP。 Web服务的这种功能使其变得如此流行。 因此,Web服务是一种独立于语言的通信方式。

Now let us look at one of the most common use case where web services are being used extensively.

现在,让我们看一下广泛使用Web服务的最常见用例之一。

Consider the figure below, suppose I have made a new cool application but I do not want to maintain the data of the users, who login to my application, but we want only authenticated users to use the application.

考虑下图,假设我已经制作了一个很酷的应用程序,但是我不想维护登录到我的应用程序的用户的数据,但是我们只希望经过身份验证的用户才能使用该应用程序。

So what should we do? One option is, we can use the web services exposed by some other third party application, to authenticate our incoming users. You must have seen this in many applications, in form of – Sign up using Facebook, Google or other third party apps. Many Websites/Apps use Facebook and Google data, using their web services, to authenticate users.

那我们该怎么办? 一种选择是,我们可以使用某些其他第三方应用程序公开的Web服务来验证传入的用户。 你必须在许多应用中已经看到了这一点,在形式- 注册使用Facebook, 谷歌或其他第三方应用。 许多网站/应用程序通过其Web服务使用Facebook和Google数据来验证用户身份。

Therefore, we do not have to maintain any data of the users to authenticate, rather we can now fully concentrate on the content of our application.

因此,我们不必维护用户的任何数据即可进行身份验证,而现在我们可以完全专注于应用程序的内容。

The flow of the authentication process will be like this:

身份验证过程的流程将如下所示:

  1. User logs into our Application.

    用户登录到我们的应用程序。

  2. We show them two options – either sign in using Facebook or Google.

    我们向他们展示了两个选项-使用Facebook或Google登录。

  3. Enter the Username and Password.

    输入用户名和密码。

  4. The application will now pass the Username and Password to Google or Facebook server using http request.

    该应用程序现在将使用http请求将用户名和密码传递给Google或Facebook服务器。

  5. The request/response can be in any format. It could be a json/xml or any other media type.

    请求/响应可以是任何格式。 它可以是json / xml或任何其他媒体类型。

  6. Now if the request is ok, Google or Facebook server will send us the response and accordingly we will authenticate our users to login into the application.

    现在,如果请求正常,Google或Facebook服务器将向我们发送响应,并相应地我们将对用户进行身份验证以登录到该应用程序。

The third party apps, who expose their APIs must provide a proper documentation of all the requests and responses. Checkout this link for the PayPal API to get some idea how documentation is done – https://developer.paypal.com/docs/api/identity/

公开其API的第三方应用程序必须提供所有请求和响应的正确文档。 查看此PayPal API链接以了解如何完成文档制作-https: //developer.paypal.com/docs/api/identity/

《什么是web服务_什么是Web服务?》

翻译自: https://www.studytonight.com/rest-web-service/introduction

什么是web服务

    原文作者:cunfen6312
    原文地址: https://blog.csdn.net/cunfen6312/article/details/107684232
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。

相关文章