Thursday, December 18, 2014

Sample Web-service method in Groovy and how to call it

You might have heard about Webservice.

 Don't just use facebook or twitter or google! 
 Understand how things work in the background. 
 Read this short blog post I wrote to learn how the pages you see and the mobile 
 apps you use communicate with servers.  

Web service is a method of communication between two electronic devices over a network. It is a software function provided at a network address over the Web with the service always on as in the concept of utility computing. The W3C defines a Web service generally as:-
a software system designed to support interoperable machine-to-machine interaction over a network.
Read what web services are from wikipedia and read the code.

Nowadays, This is how almost all new web and mobile apps work.

 class SampleController {  
     def action(String username, String course, String password){  
         return Grade.findByUsernameAndCourseAndPassword(username, course, password)
     }  
 }  

GET
 www.mu.com/sample/action?username=biniam&course=it&password=123  

POST
 www.mu.com/sample/action  
           {  
                "username":"biniam",  
                "course":"it",  
                "password":"123"  
           }  

No comments:

Post a Comment