users@glassfish.java.net

Re: JAX RS / Jersey Question

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 18 Feb 2010 10:43:35 +0100

Hi Daniel,

Have you included the jersey-json module in your dependencies?

   https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html
#d4e1218

As Markus says the Jersey users list is likely to be better place to
ask such questions, as there will be more domain experts lurking on
that list.

Paul.

On Feb 18, 2010, at 12:49 AM, glassfish_at_javadesktop.org wrote:

> If i'm posting this in the incorrect forum please let me know.
>
> I have a few simple web methods exposed over Glassfish V3 using
> Jersey / JAX RS.
> Basically, these are @GET methods and a single @POST method. My
> client implementation follows the pattern listed in the Jersey
> Documentation here:
>
> https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html
>
> Client test methods are similar to this:
> [code]
> Client c = Client.create();
> WebResource r = c.resource(“http://localhost:8080/...”);
> String response = r.accept("text/plain").post(String.class,
> request);
> [/code]
>
>
> I'm running into an issue on one of my server methods which performs
> a Post, and does some more meaniningful work. I was under the
> impression that I could ask for a JSONObject from the client, and
> receive this on the server so I did the following on the server:
>
> [code]
> @POST
> @Path("submit")
> @Consumes("application/json")
> @Produces("text/plain")
> public String doSubmit ( JSONObject object ) {
>
> // stuff
> return id;
> }
> [/code]
>
>
> The corresponding test client method for the post is listed as such:
> [code]
> Client c = Client.create();
> WebResource r = c.resource(“http://localhost:8080/submit”);
>
> JSONObject object = new JSONObject ();
> /* cofigure the object (code not shown) */
> String response = r.accept("text/plain").type("application/
> json").post(String.class, request);
> [/code]
>
> How does one send a JSONObject over post from the client to the
> server? Or is it the client's responsibility to only send strings?
> I see that there is low-level support included for JSON Objects
> according to the Jersey manual, I would think that they could be
> serialized somehow?
>
> thanks
> [Message sent by forum member 'hoffman462' (HoffmanDanielG_at_gmail.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=387280
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>