0

When providing a Restful web service (in java), is there a way to expose what are the methods and their parameters inside the service like in soap service wsdl ?

How does the consuming side of the web-service knows what are the available methods that can be used ? (I want to consume a web service only through it's URL).

I'm using NetBeans 8.0.2 with Apache Tomcat.

Thank's In Advanced.

Alexandru Marculescu
  • 5,569
  • 6
  • 34
  • 50
user2046810
  • 393
  • 1
  • 8
  • 21

2 Answers2

0

Looking at the Richardson Maturity Model, REST is all about Resources, on which HTTP Verbs (and not "methods") can be applied, discovered/exposed through Links. For example, from the top level of your API, a client could notice a products-query relationship, which would retrieve a list of product resource after being accessed through a GET request - and so on.

Another way of achieving that is wiring up Swagger on top of your API.

Alexandru Marculescu
  • 5,569
  • 6
  • 34
  • 50
0

As @Alexandru pointed out the Richardson Maturity Model, for a true RESTful service or client, the last level (usually 3 on starting with index 0) already has to be in place otherwise it is not "true" RESTful.

The core idea behind REST is the decoupling of distributed clients and servers similar to Web browsers being completly uncoulpled from any Web servers. Also, similar to a traditional Web session where you start from a certain start-page and then navigate through pages using links, the same applies to RESTful content where you start from some base resource and then use returned URIs to navigate to new resources.

Each URI starts with a protocol identifier which defines the possible actions or methods that can be performed on the referenced resource. Most often this will be HTTP but it is not limited to it and can also use something like mailto, FTP or something of that kind. Therefore, the respective protocol specification is also the documentation on the possible actions.

Which parameters need to be passed to the URI are either already set by the response of a previous request or may be templated and thus be set by the client dynamically. Here the client needs to understand how to handle templates and where to take possible values from. This can however be included in the response as well, similar to Web forms where certain choices are also provided by the server. The respective media-type (i.e. application/atom+xml or application/hal+json) supports the client on processing data by giving the content more semantical value and maybe even define certain structure the target can utilize to simplify its work.

Roman Vottner
  • 12,213
  • 5
  • 46
  • 63