简体   繁体   English

ReST Web服务客户端-是否从WSDL生成?

[英]ReST webservice client - generate from WSDL or not?

I've some confusions about ReST clients and need a bit of help. 我对ReST客户有一些困惑,需要一些帮助。

For ReST, does the service provider give WSDL document or not? 对于ReST,服务提供商是否提供WSDL文档? If not, how does the client will know what kind of JSON data to expect? 如果不是,客户端将如何知道期望什么样的JSON数据? When I invoke the rest client, I will recieve the JSON/XML response in a string format which I'll need to convert it into a Java object(or Javascript, if using on client side) to do any meaningful tasks with the response. 当我调用其余的客户端时,我将以字符串格式接收JSON / XML响应,我需要将其转换为Java对象(如果在客户端使用,则转换为Java对象)以对响应执行任何有意义的任务。 So it seems like I, as a client developer, need to know the WSDL or the Schema definition so that I can build a java object similar to the JSON response I'm expecting. 因此,作为客户端开发人员,我似乎需要了解WSDL或Schema定义,以便可以构建与期望的JSON响应类似的Java对象。 But if you go by this answer , generating a client class based on the service definition flies directly in the face of ReST fullness. 但是,如果您按此答案进行操作 ,则基于服务定义生成客户端类将直接面对ReST完整性。 If that is the case, how do I go about creating my client code? 如果是这种情况,我该如何创建客户代码?

WADL/Web Application Description Language is not a standard but is gaining popularity for REST APIs contract definition. WADL / Web应用程序描述语言不是一种标准,但是在REST API合同定义中越来越流行。

The Web Application Description Language (WADL) is a machine-readable XML description of HTTP-based web applications (typically REST web services). Web应用程序描述语言(WADL)是基于HTTP的Web应用程序(通常是REST Web服务)的机器可读XML描述。 1 WADL models the resources provided by a service and the relationships between them. 1 WADL对服务提供的资源及其之间的关系进行建模。 1 WADL is intended to simplify the reuse of web services that are based on the existing HTTP architecture of the Web. 1 WADL旨在简化基于Web现有HTTP体系结构的Web服务的重用。 1 [2] It is platform and language independent and aims to promote reuse of applications beyond the basic use in a web browser. 1 [2]它是平台和语言独立的,旨在促进应用程序的重用,超越Web浏览器的基本用途。

For documentation: 对于文档:

https://github.com/wordnik/swagger-core/tree/master/modules/swagger-jaxrs https://github.com/wordnik/swagger-core/tree/master/modules/swagger-jaxrs

For client code: 对于客户代码:

https://github.com/wordnik/swagger-ui https://github.com/wordnik/swagger-ui

  • You integrate the library and annotate your resources and online documentation is generated on the fly. 您集成库并注释资源,并且在线文档会即时生成。
  • You also need a client for which you can integrate the ui. 您还需要一个可以集成ui的客户端。

The dynamically generated REST client looks something like this: 动态生成的REST客户端如下所示:

http://petstore.swagger.wordnik.com/ http://petstore.swagger.wordnik.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM