users@jersey.java.net

[Jersey] Json (proxying) help

From: Pierre Radermecker <pradermecker_at_yahoo.ca>
Date: Fri, 7 Oct 2011 12:26:10 -0700 (PDT)

Hi,

I would like to take a Json entity object from a request and send it back (proxying) to another URI. Then I need to take the output and go on processing the initial request.

So I have something like this:


    @PUT
    @Path("gml")
    @Consumes("application/json")
    public Response myMethod(final @QueryParam("oneId") Integer oneId, JsonNode jsonInput) {
       

        // send just the jsonInput and get the output of the external webservice

        ClientResponse clientResponse  = client.resource(URL)
                .accept("application/gml+xml")
                .type(MediaType.APPLICATION_JSON_TYPE)
                .entity(jsonInput)
                .get(ClientResponse.class);
        // parse the response and go on processing
        ...

}



I don't know how I could just pass the "jsonInput" to the URL without even serializing it.

If I do have to consume the inputSteam, then I know JsonNode (jackson) works (but JSONObject doesn't). And it seems to be the opposite when I try to send jsonInput as an entity in the client.

What is the best way to handle this ?


Thanks for your help.

Regards,


- PierreR