He creado un servicio web REST con algunos métodos web. Pero no consigo que funcione pasando los parámetros a estos métodos.REST pasando Parámetros con Java
I.E.
@GET
@Path("hello")
@Produces(MediaType.TEXT_PLAIN)
public String hello(String firstName, String lastName){
return "Hello " + firstname + " " + lastname
}
¿Cómo invocaría ese método y cómo pasar los parámetros firstname y lastname? Probé algo como esto:
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
ClientResponse response = service.path("hello")
.accept(MediaType.TEXT_PLAIN).put(ClientResponse.class);
Pero ¿por dónde añadir los parámetros?
Gracias por su ayuda, mejores deseos, Chris
gracias me has ayudado mucho. Pero, ¿y si mi método quiere una matriz de cadenas? – Chris
@Chris: Esto debería ayudar: http://stackoverflow.com/questions/5484209/pass-array-as-a-parameter-in-restful-webservice – npinti
Muchas gracias. Ese enlace también fue útil para el contexto de su último enlace: http://stackoverflow.com/questions/5718575/how-can-i-grab-all-query-parameters-in-jersey-jaxrs – Chris