Permalink
Browse files

jaxb client

  • Loading branch information...
1 parent 24b0a56 commit e1ccac6dc96d98a0317ad84f4b7a66c8d2e9e685 @lixinso committed Oct 6, 2011
@@ -0,0 +1,27 @@
+package de.vogella.jersey.jaxb.client;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+
+public class Test {
+
+ public static void main(String[] args){
+ ClientConfig config = new DefaultClientConfig();
+ Client client = Client.create(config);
+ WebResource service = client.resource(getBaseURI());
+ System.out.println(service.path("rest").path("todo").accept(MediaType.TEXT_XML).get(String.class));
+ System.out.println(service.path("rest").path("todo").accept(MediaType.APPLICATION_JSON).get(String.class));
+ System.out.println(service.path("rest").path("todo").accept(MediaType.APPLICATION_XML).get(String.class));
+ }
+
+ private static URI getBaseURI(){
+ return UriBuilder.fromUri("http://localhost:8080/de.vogella.jersey.jaxb").build();
+ }
+}

0 comments on commit e1ccac6

Please sign in to comment.