> -----Original Message-----
> From: Charles W. Stanton [mailto:[EMAIL PROTECTED]
> Sent: 2008年1月15日 23:38
> To: [email protected]
> Subject: REST with different return formats
> 
> 
> I want to write RESTful services, utilizing some of the same Service classes
> I've written for our GWT client, and I need to be able to return either XML
> or JSON based on something in the URL.
> 
> For instance:
> http://myserver/someapp/json/person/{id}
> or
> http://myserver/someapp/person/{id}?format=json
> 
> Whatever seems to be a good way to do it.
> 
> I don't much care at this point if I use JAX-RS or HTTP Binding--or
> something else--and I'm open to suggestions.  My entire "server" is
> configured using Spring, so ideally this would happen via some combination
> of annotations and/or Spring configurations.
> 
> I see in the User's Guide, under the section for RESTful Services -> JAX-RS,
> that I can use annotations to define the return format as either XML _OR_
> JSON, but how might I defer making that decision until request time?
> 
[Liu, Jervis] A beauty of REST services is its ability to serve the same 
resource with multiple representations. One standard way to do this is through 
setting Accept headers in your REST client. I've put a demo in CXF to show how 
to return different content type from same REST service, it is located under 
"samples\jax_rs\content_negotiation". Grab a latest snapshot of CXF and try it 
out. Any feedbacks are highly welcome.

CXF JAX-RS doc: http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html


 
> Thank you.
> 
> Charles
> Colorado Springs
> 
> --
> View this message in context:
> http://www.nabble.com/REST-with-different-return-formats-tp14841539p1
> 4841539.html
> Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Reply via email to