Skip to content

Instantly share code, notes, and snippets.

@KomanRudden
Last active August 29, 2015 13:56
Show Gist options
  • Save KomanRudden/8901190 to your computer and use it in GitHub Desktop.
Save KomanRudden/8901190 to your computer and use it in GitHub Desktop.
JAX-RS 1.0 Client examples - RESTEasy
package i.am.koman.wsclients;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
import javax.ws.rs.core.MediaType;
public class RESTEasy_Client {
public static void main(String args[]) throws Exception {
callRESTEasy();
}
private static void callRESTEasy() throws Exception {
ClientRequest request = new ClientRequest("http://<IP Address>:8080/<path-to-rest-service>/go");
request.accept(MediaType.TEXT_PLAIN);
ClientResponse<String> response = request.get(String.class);
if (response.getStatus() != 200) {
System.out.println("BIG RESTEasy ERROR");
} else {
System.out.println("RESTEasy HAPPY DAYS");
System.out.println(response.getEntity(String.class));
}
}
}
//MAVEN Dependencies
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.2.1.GA</version>
</dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment