简体   繁体   中英

ReST webservice client - generate from WSDL or not?

I've some confusions about ReST clients and need a bit of help.

For ReST, does the service provider give WSDL document or not? If not, how does the client will know what kind of JSON data to expect? 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. 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. But if you go by this answer , generating a client class based on the service definition flies directly in the face of ReST fullness. 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.

The Web Application Description Language (WADL) is a machine-readable XML description of HTTP-based web applications (typically REST web services). 1 WADL models the resources provided by a service and the relationships between them. 1 WADL is intended to simplify the reuse of web services that are based on the existing HTTP architecture of the Web. 1 [2] It is platform and language independent and aims to promote reuse of applications beyond the basic use in a web browser.

For documentation:

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

For client code:

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.

The dynamically generated REST client looks something like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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