Saltar al contenido

llamar a rest api en el ejemplo de código de jersey java

Nuestros mejores programadores han agotado sus reservas de café, en su búsqueda noche y día por la respuesta, hasta que Daniella halló el arreglo en GitHub por lo tanto hoy la compartimos contigo.

Ejemplo: com.sun.jersey.api.client en glassfish

using jersey-client-1.9. sample code:importcom.sun.jersey.api.client.Client;importcom.sun.jersey.api.client.ClientResponse;importcom.sun.jersey.api.client.WebResource;Client client =Client.create();
webResource = client.resource("http://localhost:8047/storage/hive.json");String input =//rest requestClientResponse response = webResource.type("application/json").post(ClientResponse.class, input);String queryRespose = response.getEntity(String.class);Asthis project has changed from com.sun.jersey.api.client toorg.glassfish.jersey.client.Howtoachievethis in jersey-client-2.8?ConvertedCode:=================importjavax.ws.rs.client.Client;importjavax.ws.rs.client.ClientBuilder;importjavax.ws.rs.client.Entity;importjavax.ws.rs.client.WebTarget;importjavax.ws.rs.core.Response;Client client =ClientBuilder.newClient();WebTarget target = client.target("http://localhost:8047/query.json");String input =//rest requestResponse response = target.request().post(Entity.json(input));String queryRespose = response.readEntity(String.class);This worked...:)

Sección de Reseñas y Valoraciones

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *