How to implement REST web-services? -


i trying learn java web-service using rest architecture. far have created class don't know how consume service. here's code:

import javax.ws.rs.get; import javax.ws.rs.produces; import javax.ws.rs.path;   @path("/sericecreation") public class sericecreation {      @get     @produces("text/plain")     public string display(){         return "hello";     }  } 

now, want call display method. can me understand how can achieved?

in simplified point of view, rest services bound http calls, in example @get annotation tells method accessed making http get call.

you can point browser url generated service , should see "hello" response. url http://<server>:<port>/<appcontext>/<rest-servlet-mapping>/sericecreation where:

  • <server> server name. typically localhost
  • <port> default server port number. if usin jboss 8080
  • <appcontext> typically name of applicaction (war file)
  • <rest-servlet-mapping> resteasy or jersey frameworks servlet path
  • /sericecreation comes @path annotation used
    in class.

another way intereact services using rest client one.

and of course, if want create java client can use apache http client library, java.net.* package or others. remember, rest services accessed making http calls.

i recommend read 2 tutorials general idea of rest architecture.

this great tutorial shows lot of examples using jersey or resteasy in order implement java rest services.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -