Was trying to find a Javascript client for REST api. Seems like there isnt a one available. The idea is simple if you have a Java class annotated using JSR 311 annotations than one can write a tool like DWR that can at compile time or at runtime introspect Java classes and generate a stub.
If there is a class like
than requesting a script like /Jersey/RESTClient/HelloWorldResource.js should generate a javascript class that takes primitives/JSON as method params and form a proper REST Url and invoke the URL and gets the result and returns it using AJAX. I am unable to find a library like this so far therefore will try to write one
If there is a class like
1 // The Java class will be hosted at the URI path "/helloworld"
2 @Path("/helloworld")
3 public class HelloWorldResource {
4
5 // The Java method will process HTTP GET requests
6 @GET
7 // The Java method will produce content identified by the MIME Media
8 // type "text/plain"
9 @Produces("text/plain")
10 public String getClichedMessage() {
11 // Return some cliched textual content
12 return "Hello World";
13 }
14 }
than requesting a script like /Jersey/RESTClient/HelloWorldResource.js should generate a javascript class that takes primitives/JSON as method params and form a proper REST Url and invoke the URL and gets the result and returns it using AJAX. I am unable to find a library like this so far therefore will try to write one
Try something like this http://sasajovancic.blogspot.com/2011/06/javascript-rest-client.html
ReplyDelete