users@jersey.java.net

Re: [Jersey] Formats supported by the default OPTIONS & HEAD methods

From: Felipe Gaścho <fgaucho_at_gmail.com>
Date: Fri, 15 Jan 2010 18:54:06 +0100

ok, I was just curious about.. no big deal..

On Fri, Jan 15, 2010 at 6:51 PM, Marc Hadley <Marc.Hadley_at_sun.com> wrote:
> On Jan 15, 2010, at 10:42 AM, Santiago Pericas-Geertsen wrote:
>
>> On Jan 15, 2010, at 3:50 AM, Felipe Gaścho wrote:
>>
>>> I tried to get a JSON response from the auto-generated OPTIONS method
>>> in my service but it seems only to respond in XML format.
>>>
>>> is it correct ? Does it make sense to expect JSON also in the options
>>> and head methods ?
>>
>> There isn't a JSON representation of WADL that I know of (Marc?). Is that what you expected?
>>
> We haven't defined any kind of normative JSON serialization for WADL, only XML is supported. HEAD is giving you the supported representation of the resource whereas OPTIONS is getting the WADL metadata about the resource, I suspect that is why HEAD returns with a JSON content type.
>
> Marc.
>
>>>
>>> example:
>>>
>>> curl -v -H 'Accept: application/json' -XOPTIONS
>>> http://fgaucho.dyndns.org:8080/arena-http/institution
>>>
>>> * About to connect() to fgaucho.dyndns.org port 8080 (#0)
>>> *   Trying 84.75.167.99... connected
>>> * Connected to fgaucho.dyndns.org (84.75.167.99) port 8080 (#0)
>>>> OPTIONS /arena-http/institution HTTP/1.1
>>>> User-Agent: curl/7.19.6 (sparc-sun-solaris2.8) libcurl/7.19.6 OpenSSL/0.9.7g zlib/1.2.3
>>>> Host: fgaucho.dyndns.org:8080
>>>> Accept: application/json
>>>
>>> < HTTP/1.1 200 OK
>>> < X-Powered-By: Servlet/3.0
>>> < Server: GlassFish v3
>>> < Allow: OPTIONS,POST,GET,HEAD
>>> < Content-Type: application/vnd.sun.wadl+xml
>>> < Content-Length: 1897
>>> < Date: Fri, 15 Jan 2010 08:45:05 GMT
>>> <
>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?><application
>>> xmlns="http://research.sun.com/wadl/2006/10"><doc
>>> xmlns:jersey="http://jersey.dev.java.net/" jersey:generatedBy="Jersey:
>>> 1.1.4.1 11/24/2009 01:37 AM"/><resources
>>> base="http://fgaucho.dyndns.org:8080/arena-http/"><resource
>>> path="institution"><method id="update"
>>> name="POST"><request><representation
>>> mediaType="application/xml"/><representation
>>> mediaType="application/json"/></request><response><representation
>>> mediaType="application/xml"/><representation
>>> mediaType="application/json"/></response></method><method
>>> id="selectAllByRole" name="GET"><request><param
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema" name="start" style="query"
>>> type="xs:int" default="0"/><param
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema" name="max" style="query"
>>> type="xs:int" default="50"/><param
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema" name="role" style="query"
>>> type="xs:string"/></request><response><representation
>>> mediaType="application/xml"/><representation mediaType="applica*
>>> Connection #0 to host fgaucho.dyndns.org left intact
>>> * Closing connection #0
>>> tion/json"/></response></method><resource path="count"><method
>>> id="count" name="GET"><response><representation
>>> mediaType="text/plain"/></response></method></resource><resource
>>> path="{acronym}"><param xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>> name="acronym" style="template" type="xs:string"/><method id="delete"
>>> name="DELETE"><response><representation
>>> mediaType="*/*"/></response></method><method id="create"
>>> name="POST"><response><representation
>>> mediaType="application/xml"/><representation
>>> mediaType="application/json"/></response></method></resource><resource
>>> path="{id}"><param xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>> name="id" style="template" type="xs:string"/><method id="select"
>>> name="GET"><response><representation
>>> mediaType="application/xml"/><representation
>>> mediaType="application/json"/></response></method></resource></resource></resources></application>
>>>
>>> ---------
>>>
>>> HEAD returns JSON, but head has no payload anyway.. so it is just to
>>> know the supported content type......
>>>
>>> curl -v -H 'Accept: application/json' -XHEAD
>>> http://fgaucho.dyndns.org:8080/arena-http/institution
>>>
>>> * About to connect() to fgaucho.dyndns.org port 8080 (#0)
>>> *   Trying 84.75.167.99... connected
>>> * Connected to fgaucho.dyndns.org (84.75.167.99) port 8080 (#0)
>>>> HEAD /arena-http/institution HTTP/1.1
>>>> User-Agent: curl/7.19.6 (sparc-sun-solaris2.8) libcurl/7.19.6 OpenSSL/0.9.7g zlib/1.2.3
>>>> Host: fgaucho.dyndns.org:8080
>>>> Accept: application/json
>>>>
>>> < HTTP/1.1 200 OK
>>> < X-Powered-By: Servlet/3.0
>>> < Server: GlassFish v3
>>> < Content-Type: application/json
>>> < Content-Length: 0
>>> < Date: Fri, 15 Jan 2010 08:48:15 GMT
>>> <
>>> * Connection #0 to host fgaucho.dyndns.org left intact
>>> * Closing connection #0
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>



-- 
------------------------------------------
   Felipe Gaścho
   10+ Java Programmer
   CEJUG Senior Advisor