[英]What is WSDL equivalent in restful WS . If nothing,how consumer generates required client side classes?
Say ,i have producer in java and consumer in dot net. 说,我在java网络中有生产者,在dot网络中有消费者。 Producer has a method that takes Employee as method parameter and creates employee in db.
Producer有一个方法,它将Employee作为方法参数并在db中创建employee。
For SOAP based ws, dot net client will hit WSDL and creates the stubs (including employee data representation in dot net). 对于基于SOAP的ws,dot net client将命中WSDL并创建存根(包括dot net中的员工数据表示)。 Now it can fill the object and send to producer.
现在它可以填充对象并发送给制作人。
I am not sure how it will work in restful webservices as there is no WSDL. 我不确定它在restful webservices中是如何工作的,因为没有WSDL。 How rest consumer will get to know what are the operations exposed by producer without any WSDL contract and how dot net consumer will get stubs (like employee data object) so that it can simply fill it and send across?
休息用户如何知道生产者在没有任何WSDL合同的情况下暴露的操作,以及dot net consumer将如何获得存根(如员工数据对象)以便它可以简单地填充并发送?
I know there is WADL(parallel to WSDL) in rest but looks like its not very prominent and not a standard as of now. 我知道在休息时有WADL(与WSDL并行),但看起来不是很突出,而且现在还不是标准。
I am not getting how client side code will generate EmployeeData class so that it can fill it and send to producer? 我没有得到客户端代码将如何生成EmployeeData类,以便它可以填充它并发送给生产者? Will client manually create extra class (instead of proxy EmployeeData that used to be generated on the basis of WSDL using utilities available at client side)?
客户端是否会手动创建额外的类(而不是使用客户端可用的实用程序在WSDL的基础上生成的代理EmployeeData)? Even if client has to do it manually, how client will know what is the class definition of EmployeeData class without wsdl or wadl?
即使客户端必须手动完成,客户端如何知道没有wsdl或wadl的EmployeeData类的类定义是什么?
One important concept of REST is HATEOAS or Hypermedia as the Engine of Application State . REST的一个重要概念是HATEOAS或Hypermedia作为应用程序状态的引擎 。 What this means is that your client interacts with the REST service through hypermedia links that the service hands it.
这意味着您的客户端通过服务提供的超媒体链接与REST服务进行交互。
Your REST web service has an entry point, say http://yourhost.com/rest
. 您的REST Web服务有一个入口点,比如
http://yourhost.com/rest
。 Your client will start by sending the request to that URL. 您的客户端将首先将请求发送到该URL。 Your service will respond with a resource that describes some or all the accessible resources and how to access them.
您的服务将使用描述部分或全部可访问资源以及如何访问它们的资源进行响应。 You keep discovering and following links.
您不断发现并关注链接。 This is how the API is published (and discovered).
这就是API的发布(和发现)的方式。
Here's an awesome video describing this concept: Hypermedia APIs. 这是一个描述这个概念的精彩视频: 超媒体API。
Through HATEOAS you can make your service API completely discoverable by just following hypermedia links. 通过HATEOAS,您只需按照超媒体链接即可完全发现您的服务API。
There is no concept of top down/bottom up design in REST. REST中没有自顶向下/自底向上设计的概念。
REST is about resources, not about method calls, which is basically what a WSDL describes. REST是关于资源的,而不是关于方法调用的,这基本上是WSDL描述的内容。
Even if client has to do it manually, how client will know what is the class definition of EmployeeData class without wsdl or wadl?
即使客户端必须手动完成,客户端如何知道没有wsdl或wadl的EmployeeData类的类定义是什么?
It won't need to create an EmployeeData
class. 它不需要创建
EmployeeData
类。 Say you needed to create a new Employee
, you would send a GET request to /employees
which would possibly return a response containing how to do that. 假设您需要创建一个新的
Employee
,您将向/employees
发送一个GET请求,该请求可能会返回包含如何执行此操作的响应。 That might be an XHTML response like so (among other things) 这可能是像这样的XHTML响应(除其他外)
<form class="new-employee" action="/context/employees" method="PUT" >
<input type="text" name="employee_name" />
<input type="text" name="employee_age" />
<input type="submit" name="submit" />
</form>
The response contains the exact format you need to follow to create a new employee. 响应包含创建新员工时需要遵循的确切格式。 You need to submit the form to
/context/employees
with an HTTP PUT request containing those form parameters. 您需要使用包含这些表单参数的HTTP PUT请求将表单提交给
/context/employees
。 This is HATEOAS. 这是HATEOAS。 The hypermedia link is the
/context/employees
. 超媒体链接是
/context/employees
。 The engine is following this link with a PUT request. 引擎通过PUT请求跟随此链接。 The application state is that after this request, a new employee will exist.
应用程序状态是在此请求之后,将存在新员工。
Assuming that you're using the Json based WS - there is some tools that helps: 假设您正在使用基于Json的WS - 有一些工具可以帮助:
There is no (or at least I don't know about it) tool that allow to generate stub, data classes etc. as it can ve usually done with WSDL file. 没有(或者至少我不知道)工具允许生成存根,数据类等,因为它通常可以通过WSDL文件完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.