Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. Producer has a method that takes Employee as method parameter and creates employee in db.

For SOAP based ws, dot net client will hit WSDL and creates the stubs (including employee data representation in 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. 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?

I know there is WADL(parallel to WSDL) in rest but looks like its not very prominent and not a standard as of now.

I am not getting how client side code will generate EmployeeData class so that it can fill it and send to producer? 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)? Even if client has to do it manually, how client will know what is the class definition of EmployeeData class without wsdl or wadl?

like image 612
M Sach Avatar asked Mar 15 '14 18:03

M Sach


1 Answers

One important concept of REST is HATEOAS or Hypermedia as the Engine of Application State. What this means is that your client interacts with the REST service through hypermedia links that the service hands it.

Your REST web service has an entry point, say http://yourhost.com/rest. Your client will start by sending the request to that 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).

Here's an awesome video describing this concept: Hypermedia APIs.

Through HATEOAS you can make your service API completely discoverable by just following hypermedia links.


There is no concept of top down/bottom up design in REST.

REST is about resources, not about method calls, which is basically what a WSDL describes.

Even if client has to do it manually, how client will know what is the class definition of EmployeeData class without wsdl or wadl?

It won't need to create an EmployeeData class. 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. That might be an XHTML response like so (among other things)

<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. This is HATEOAS. The hypermedia link is the /context/employees. The engine is following this link with a PUT request. The application state is that after this request, a new employee will exist.

like image 61
Sotirios Delimanolis Avatar answered Sep 28 '22 09:09

Sotirios Delimanolis