1 |
torben |
2516 |
package dk.thoerup.webservice; |
2 |
|
|
|
3 |
|
|
import javax.ws.rs.GET; |
4 |
|
|
import javax.ws.rs.Path; |
5 |
|
|
import javax.ws.rs.Produces; |
6 |
|
|
import javax.ws.rs.core.MediaType; |
7 |
|
|
|
8 |
|
|
@Path("/Rest") |
9 |
|
|
public class RestSimpleJerseyTest { |
10 |
|
|
|
11 |
|
|
public static class TestResponse { |
12 |
|
|
public int id; |
13 |
|
|
public String name; |
14 |
|
|
|
15 |
|
|
public TestResponse(int i, String n) { |
16 |
|
|
this.id = i; |
17 |
|
|
this.name = n; |
18 |
|
|
} |
19 |
|
|
|
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
@Path("/Simple") |
23 |
|
|
@GET |
24 |
|
|
@Produces(MediaType.TEXT_PLAIN) |
25 |
|
|
public String getIt() { |
26 |
|
|
return "Got it!"; |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
@Path("/Object") |
30 |
|
|
@GET |
31 |
|
|
@Produces({"application/xml", "application/json"}) |
32 |
|
|
public TestResponse getObj() { |
33 |
|
|
return new TestResponse(1, "Hej"); |
34 |
|
|
} |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
} |