On Feb 14, 2008, at 1:08 PM, Joachim Martin wrote:
> Is your client sending "Accept: application/json"?
>
Exactly. Content negotiation is currently based solely on the HTTP
Accept header. The JSR 311 expert group has discussed (but not
finalized) support for URI based conneg such that:
GET
http://example.com/foo.xml
GET
http://example.com/foo.json
would be equivalent to
GET
http://example.com/foo
with "Accept: application/xml" or "Accept: application/json"
respectively. Support for this will appear in due course once a firm
proposal is accepted by the EG.
BTW, for testing from a browser I've found the Firefox plug-in
"Poster" to be very useful. It lets you specify the HTTP method, set
HTTP request headers and send arbitrary content in the body of requests.
Marc.
>
> Manveen Kaur wrote:
>> I'm using Jersey to develop my restful services and had a few
>> questions.
>>
>> Lets say I have an implementation of my service as below,
>>
>> @UriTemplate("/myresource/")
>> public class MyResource {
>> @HttpMethod
>> @ProduceMime({"application/xml", "application/json"})
>> public JAXBBean get() {
>> JAXBBean j = ...
>> return j;
>> }
>> }
>>
>> 1. What do I need to do (which URI to invoke) in my client if I
>> want to get the result in JSON format.
>> 2. If I just use the URI http://mydomain/myresource/, then xml
>> would be returned by default.
>> How do I make JSON data to be returned as default?
>>
>> Thanks
>> Manveen
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.