users@jersey.java.net

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

From: Santiago Pericas-Geertsen <Santiago.Pericasgeertsen_at_Sun.COM>
Date: Fri, 15 Jan 2010 10:42:35 -0500

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?

-- Santiago

>
> 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
>