I'm using the following code to create WebService without configuration in web.xml like described here: How to set up JAX-RS Application using annotations only (no web.xml)?
@ApplicationPath("/host")
@Path("/merge")
public class FormProvider extends Application {
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getFormByKey(@QueryParam("key") String key) {
Form form = DB.getFormByKey(key);
Gson gson = new GsonBuilder()
.setPrettyPrinting()
.create();
String json = gson.toJson(form);
return json;
}
}
And using following URL to invoke WebService with parameters:
http://localhost:9081/MyRestApplication/host/merge?key=xyz123
Webservice being invoked but property key
remains empty, what am I doing wrong?
Thank you.
Update: It began to work. I can't explain but I just removed jax-rs library, turned-off server and then turned-on and added library (same library) back and it began to work. Before it I tried to perform clean, build, nothing helped. If somebody will be able to explain what and why did it happen, I will accept it as answer. Thank you.