Crazenezz
Crazenezz

Reputation: 3456

Using GET parameters in Play Web Service?

I tried to build Web Service Server using Play Framework 1.2.3 and got some problem:

  1. I tried this tutorial How to use play! framework to develop webservice. I don't know how to request the web service using GET parameters, how to request the web service using parameters?
  2. Is it possible to return the result with GIF file in Play? If yes, can anyone provide an example or link for that (tried to googling it before, but no result)?

Thanks for your help...

Upvotes: 0

Views: 402

Answers (1)

Codemwnci
Codemwnci

Reputation: 54884

For the webservice described, it should be quite easy. for example, if you have an action as follows

public class Application extends Controller {


    public static void sum(Float num1, Float num2) {
        Float result = num1 * num2;
        render(result);
    }
}

and a route of

GET /webservices/sum                 Application.sum(format:'xml')

then all you need to do is call the service like the following

/webservices/sum?num1=10.1&num2=13.5

this will execute your action by passing in the required parameters

For your second part of the question. You would use renderBinary in your action to return your GIF file.

Upvotes: 1

Related Questions