1 package at.meikel.dmrl.client.portlet;
2
3 import javax.ws.rs.core.MediaType;
4
5 import net.sf.json.JSONArray;
6 import net.sf.json.JSONObject;
7
8 import com.sun.jersey.api.client.Client;
9 import com.sun.jersey.api.client.WebResource;
10
11 public class JerseyClient {
12
13
14
15
16
17 public static void main(String[] args) {
18
19
20
21
22 String[] services = new String[] { "/players/byLicenseId/37225",
23 "/playersByTeam/SG%20Weiterstadt%201886"
24
25 Client c = Client.create();
26 WebResource r = c.resource("http://dmrl.meikel.cloudbees.net:80/rest");
27
28 for (String path : services) {
29 String response = r.path(path).accept(
30 MediaType.APPLICATION_JSON_TYPE).get(String.class);
31 System.out
32 .println("==================================================");
33 System.out.println(path);
34 System.out
35 .println("==================================================");
36 System.out.println(response);
37 try {
38 JSONObject json = JSONObject.fromObject(response);
39 System.out.println(json);
40 } catch (Exception e1) {
41 try {
42 JSONArray json = JSONArray.fromObject(response);
43 System.out.println(json);
44 } catch (Exception e2) {
45
46 }
47 }
48
49 System.out.println();
50 System.out.println();
51 System.out.println();
52 System.out.println();
53 System.out.println();
54 }
55
56
57
58
59
60
61
62
63 }
64 }