0

I have an jax-rs endpoint as below. I need to post a message to a web page through this endpoint. When I execute the endpoint using a client the method with @GET executes. But the method with @POST does not execute. I need to know when will be the @POST method will execute. What should I do to invoke the @POST method.

 @GET
@Path("/")
@Produces("text/plain")

    public boolean getLoginStatus(@Context HttpServletRequest request) throws URISyntaxException {
return true;
}

 @POST
@Path("/")
public boolean helloPost() {
    return true;
}
Hasanthi
  • 1,251
  • 3
  • 14
  • 30
  • It's up to the client what kind of request it issues. See http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods. If your client is a browser, it will probably use GET unless you are entering data into a form; I don't think there's any way to control that. There are tools like Postman that will let you decide what request you want to try. – ajb Apr 02 '15 at 07:00
  • hi ajb thanks for the response. Actually my client is posting message to the endpoint using postMessage. When I'm posting a message to the endpoint, the method with @post annotation should be invoked. isn't it? But it is not invoking :( postMessage(message,'https://localhost:9443/oauth2/session'); – Hasanthi Apr 02 '15 at 07:08
  • But is it using POST? – ajb Apr 02 '15 at 07:10
  • That is what i need to know actually. I should get the response from the endpoint and show from an iFrame which includes the endpoint. – Hasanthi Apr 02 '15 at 07:12

1 Answers1

0

You need to invoke a HTTP POST request from your client - be it a programmatic one (e.g. JAX-RS 2.0 client API), a browser or tools like curl etc. I would strongly suggest using Postman client as a chrome browser extension to execute a POST request and test out your REST service

Abhishek
  • 1,175
  • 1
  • 11
  • 21