Mark,
Thanks very much for your Response (couldn't resist).
My Customer is a JAXB object; my RESTful GET methods just return "Customer" objects and they show up as XML on my iOS client perfectly.
I'm still pretty shaky on the usage of the Response. I tried this:
return Response.ok(customer).type("application/xml").build();
Looks like I'm getting the serialized *customer* object in the response on my iOS client now. What I am doing wrong that is preventing the response from being encoded to XML?
Thanks again,
Greg
----- Original Message -----
From: "Mark Petrovic" <mspetrovic_at_gmail.com>
To: "<jamesgc21_at_comcast.net>" <jamesgc21_at_comcast.net>
Cc: users_at_jersey.java.net
Sent: Thursday, December 30, 2010 7:39:06 PM
Subject: Re: [Jersey] Problems Reading javax.ws.rs.core.Response from POST
Jersey can serialize a JAXB object with no additional programming on your part. So if *customer* is a JAXB object, then setting it as the entity on the Response is all you need to do:
return ...entity(customer).build();
If Customer is not a JAXB object, then you need to supply code to translate it into one, or just build the XML representation of Customer manually into a String and set that as the Response entity().
On Dec 30, 2010, at 6:14 PM, <jamesgc21_at_comcast.net> wrote:
> I just started implementing REST with JAX-RS this week. Working
> through the examples in the RESTful Java text by Burke.
>
> Successful in querying data from a PostgreSQL database using GET
> methods from an iOS client. Have also been able to create new records
> using POST, but can't seem to figure out how to read/parse the
> javax.ws.rs.core.Response from my POST method. Trying to read the
> response to verify if the POST (create) was successful.
>
> @POST
> @Consumes("application/xml")
> public Response createCustomer(Customer customer) {
> //code here to create a new Customer record...(this part is
> working)
> return Response.created(URI.create("/customers/" +
> customer.getId())).build();
> }
>
> When I read the response in my iOS client...nothing shows up. Assuming
> that the return value is XML. Do I need to change the return
> type...aka build/return an actual XML String?
>
> Any advice would be appreciated.