什么是Web服务端点?

本文翻译自:What is a web service endpoint?

Let's say my web service is located at http://localhost:8080/foo/mywebservice and my WSDL is at http://localhost:8080/foo/mywebservice?wsdl . 假设我的Web服务位于http://localhost:8080/foo/mywebservice而WSDL位于http://localhost:8080/foo/mywebservice?wsdl

Is http://localhost:8080/foo/mywebservice an endpoint, ie, is it the same as the URI of my web service or where the SOAP messages received and unmarshalled? http://localhost:8080/foo/mywebservice是端点吗,即,它与我的Web服务的URI相同还是在SOAP消息的接收和解组位置?

Could you please explain to me what it is and what the purpose of it is? 您能给我解释一下它的含义和目的吗?


#1楼

参考:https://stackoom.com/question/f9La/什么是Web服务端点


#2楼

This is a shorter and hopefully clearer answer... Yes, the endpoint is the URL where your service can be accessed by a client application. 这是一个简短但希望更清晰的答案...是的,端点是客户端应用程序可以访问您的服务的URL。 The same web service can have multiple endpoints, for example in order to make it available using different protocols. 相同的Web服务可以具有多个端点,例如为了使用不同的协议使其可用。


#3楼

In past projects I worked on, the endpoint was a relative property. 在我以前从事的项目中,端点是相对属性。 That is to say it may or may not have been appended to, but it always contained the protocol://host:port/partOfThePath . 也就是说,它可能已附加,也可能未附加,但始终包含protocol://host:port/partOfThePath

If the service being called had a dynamic part to it, for example a ?param=dynamicValue , then that part would get added to the endpoint. 如果被调用的服务具有动态部分,例如?param=dynamicValue ,则该部分将被添加到端点。 But many times the endpoint could be used as is without having to be amended. 但是很多时候端点可以按原样使用而不必进行修改。

Whats important to understand is what an endpoint is not and how it helps. 重要的是要了解端点不是什么以及它如何提供帮助。 For example an alternative way to pass the information stored in an endpoint would be to store the different parts of the endpoint in separate properties. 例如,传递存储在端点中的信息的另一种方法是将端点的不同部分存储在单独的属性中。 For example: 例如:

hostForServiceA=someIp
portForServiceA=8080
pathForServiceA=/some/service/path
hostForServiceB=someIp
portForServiceB=8080
pathForServiceB=/some/service/path

Or if the same host and port across multiple services: 或者,如果同一主机和端口跨多个服务:

host=someIp
port=8080
pathForServiceA=/some/service/path
pathForServiceB=/some/service/path

In those cases the full URL would need to be constructed in your code as such: 在这种情况下,将需要在您的代码中这样构造完整的URL:

String url = "http://" + host + ":" + port + pathForServiceA  + "?" + dynamicParam + "=" + dynamicValue;

In contract this can be stored as an endpoint as such 在合同中,它可以这样存储为端点

serviceAEndpoint=http://host:port/some/service/path?dynamicParam=

And yes many times we stored the endpoint up to and including the '='. 是的,很多时候我们将端点存储到'='并包含在内。 This lead to code like this: 这导致这样的代码:

String url = serviceAEndpoint + dynamicValue;

Hope that sheds some light. 希望能阐明一点。


#4楼

A web service endpoint is the URL that another program would use to communicate with your program. Web服务端点是另一个程序用来与您的程序进行通信的URL。 To see the WSDL you add ?wsdl to the web service endpoint URL. 要查看WSDL,请将?wsdl添加到Web服务端点URL。

Web services are for program-to-program interaction, while web pages are for program-to-human interaction. Web服务用于程序到程序的交互,而网页用于程序到人的交互。

So: Endpoint is: http://www.blah.com/myproject/webservice/webmethod 所以:端点是: http://www.blah.com/myproject/webservice/webmethod : http://www.blah.com/myproject/webservice/webmethod

Therefore, WSDL is: http://www.blah.com/myproject/webservice/webmethod?wsdl 因此,WSDL是: http://www.blah.com/myproject/webservice/webmethod?wsdl : http://www.blah.com/myproject/webservice/webmethod?wsdl


To expand further on the elements of a WSDL, I always find it helpful to compare them to code: 为了进一步扩展WSDL的元素,我总是发现将它们与代码进行比较很有帮助:

A WSDL has 2 portions (physical & abstract). WSDL有2部分(物理部分和抽象部分)。

Physical Portion: 物理部分:

Definitions - variables - ex: myVar, x, y, etc. 定义-变量-例如:myVar,x,y等

Types - data types - ex: int, double, String, myObjectType 类型-数据类型-例如:int,double,String,myObjectType

Operations - methods/functions - ex: myMethod(), myFunction(), etc. 操作-方法/功能-例如:myMethod(),myFunction()等。

Messages - method/function input parameters & return types 消息-方法/函数输入参数和返回类型

  • ex: public myObjectType myMethod( String myVar) 例如:public myObjectType myMethod( String myVar)

Porttypes - classes (ie they are a container for operations) - ex: MyClass{}, etc. 端口类型-类(即它们是用于操作的容器)-例如:MyClass {},等等。

Abstract Portion: 摘要部分:

Binding - these connect to the porttypes and define the chosen protocol for communicating with this web service. 绑定-这些连接到端口类型并定义用于与此Web服务通信的所选协议。 - a protocol is a form of communication (so text/SMS, vs. phone vs. email, etc.). -协议是一种通信形式(因此,文本/ SMS,电话,电子邮件等)。

Service - this lists the address where another program can find your web service (ie your endpoint ). 服务-这列出了另一个程序可以在其中找到您的Web服务的地址(即, 端点 )。


#5楼

Simply put, an endpoint is one end of a communication channel. 简而言之,端点是通信通道的一端。 When an API interacts with another system, the touch-points of this communication are considered endpoints. 当API与另一个系统交互时,此通信的接触点被视为端点。 For APIs, an endpoint can include a URL of a server or service. 对于API,端点可以包括服务器或服务的URL。 Each endpoint is the location from which APIs can access the resources they need to carry out their function. 每个端点都是API可以从其访问其执行功能所需资源的位置。

APIs work using 'requests' and 'responses.' API使用“请求”和“响应”来工作。 When an API requests information from a web application or web server, it will receive a response. 当API从Web应用程序或Web服务器请求信息时,它将收到响应。 The place that APIs send requests and where the resource lives, is called an endpoint. API发送请求的地方以及资源所在的地方称为端点。

Reference: https://smartbear.com/learn/performance-monitoring/api-endpoints/ 参考: https : //smartbear.com/learn/performance-monitoring/api-endpoints/


#6楼

An Endpoint is specified as a relative or absolute url that usually results in a response. 端点被指定为通常导致响应的相对或绝对URL。 That response is usually the result of a server-side process that, could, for instance, produce a JSON string. 该响应通常是服务器端进程的结果,该进程可以例如生成JSON字符串。 That string can then be consumed by the application that made the call to the endpoint. 然后,该字符串可以由调用端点的应用程序使用。 So, in general endpoints are predefined access points, used within TCP/IP networks to initiate a process and/or return a response. 因此,一般而言,端点是预定义的访问点,在TCP / IP网络中使用它们来启动进程和/或返回响应。 Endpoints could contain parameters passed within the URL, as key value pairs, multiple key value pairs are separated by an ampersand, allowing the endpoint to call, for example, an update/insert process; 端点可以包含在URL内传递的参数,因为键值对,多个键值对之间用&符号分隔,从而允许端点调用例如更新/插入过程; so endpoints don't always need to return a response, but a response is always useful, even if it is just to indicate the success or failure of an operation. 因此,端点不一定总是需要返回响应,但是响应总是很有用的,即使只是表明操作成功或失败也是如此。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值