1 |
torben |
2516 |
package dk.thoerup.webservice; |
2 |
|
|
|
3 |
torben |
2517 |
import java.io.Serializable; |
4 |
|
|
|
5 |
torben |
2516 |
import javax.ws.rs.GET; |
6 |
|
|
import javax.ws.rs.Path; |
7 |
|
|
import javax.ws.rs.Produces; |
8 |
|
|
import javax.ws.rs.core.MediaType; |
9 |
torben |
2517 |
import javax.xml.bind.annotation.XmlRootElement; |
10 |
torben |
2516 |
|
11 |
torben |
2517 |
@Path("/samples") |
12 |
torben |
2516 |
public class RestSimpleJerseyTest { |
13 |
|
|
|
14 |
torben |
2517 |
|
15 |
|
|
@Path("/simple") |
16 |
torben |
2516 |
@GET |
17 |
|
|
@Produces(MediaType.TEXT_PLAIN) |
18 |
|
|
public String getIt() { |
19 |
|
|
return "Got it!"; |
20 |
|
|
} |
21 |
|
|
|
22 |
torben |
2517 |
@Path("/json") |
23 |
torben |
2516 |
@GET |
24 |
torben |
2517 |
@Produces(MediaType.APPLICATION_JSON) |
25 |
|
|
public TestResponse getJSON() { |
26 |
torben |
2516 |
return new TestResponse(1, "Hej"); |
27 |
|
|
} |
28 |
|
|
|
29 |
torben |
2517 |
@Path("/xml") |
30 |
|
|
@GET |
31 |
|
|
@Produces(MediaType.APPLICATION_XML) |
32 |
|
|
public TestResponse getXML() { |
33 |
|
|
return new TestResponse(1, "Hej"); |
34 |
|
|
} |
35 |
|
|
|
36 |
torben |
2516 |
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
} |