Hello,
response code is usually automatically set by runtime, so 204 for
null/blank responses, 200 for responses with entity and [45]* for
errors, but you can set whatever response code you want by returing
Response class directly, i.e.:
@GET
public Response get() {
return Response.status(200).entity(myEntity).build();
}
there is no annotation which would enable that, I cannot think of how
that should work.
Providing this information in wadl is different thing. It is possible,
but not automated, see extended-wadl-webapp sample [1], class
ItemResource. Basically we have some plugin which is capable to gather
this information from javadoc, so you need to explicitly provide
information about response codes you are going to return from your
resource methods (there is no simple way how we could get this info from
reflection api).
Regards,
Pavel
[1]
http://search.maven.org/remotecontent?filepath=com/sun/jersey/samples/extended-wadl-webapp/1.16/extended-wadl-webapp-1.16-gf-project.zip
On 12/12/12 11:23 AM, Jens Kristian Villadsen wrote:
> Hi all -
>
> AFAIK, I can't seem to find any annotations defined in the jersey
> framework that supports setting response status codes on methods. Is
> it at all possible, or am I required to write a custom annotation and
> custom wadl builder.
>
> If it is possible, could I then be able to bind certain status codes
> with certain entries from the grammar section, eg. like in the
> standard (http://www.w3.org/Submission/wadl/#x3-40001.3)?
>
> --
> Med venlig hilsen / Kind regards
>
> Jens Kristian Villadsen
> cand.polyt
> Systemudvikler / System developer
> IM (Skype): j.kidd.o
> Cetrea A/S, Denmark
>
> phone : +45 38 40 05 81
> address: Brendstrupgårdsvej 21F, DK-8200 Aarhus N.
> e-mail : jkv_at_cetrea.com <mailto:jkv_at_cetrea.com>
> w^3 : http://www.cetrea.com/
>