On Mon, Dec 19, 2011 at 10:47 PM, Sergey Beryozkin <[email protected]> wrote:
> Hi
> On 19/12/11 18:53, K Fung wrote:
>>
>> Hi David,
>>
>> In our organization, we return a Response object with our own entity and
>> explicitly set the response code. It doesn't look as if MessageBodyWriter
>> exposes a way to set the response code (by that time, it's probably too
>> late - I haven't confirmed this in the source code though). Even inside an
>> ExceptionMapper, you need to return a Response object if you want to set
>> both the entity and response code at the same time.
>>
>
> Yes, using Response is one approach; MessageBodyWriters can set Content-Type
> and other headers on the mutable map of headers - but that usually implies
> that one has to write a custom provider or at least extend one of the
> providers shipped with CXF.
> Response filters can do it too.
>
> The advantage of using specific  types is that that can be better
> represented in auto-generated WADL though Response may be adequately
> described too; Client proxies will work better with concrete types - but
> that can be considered a marginal advantage

Is there a way to use the annotations to get the WADL effect of a
specific return type?

>
> Cheers, Sergey
>
>> Regards,
>> kl
>>
>> On Mon, Dec 19, 2011 at 10:05 AM, KARR, DAVID<[email protected]>  wrote:
>>
>>> In my relatively simple JAX-RS services, I return a Java object that's
>>> serialized to XML or JSON.  I typically don't set the HTTP status code.
>>>  If
>>> I remember correctly, if instead of just returning my Java object, I use
>>> a
>>> pure "javax.ws.rs.core.Response" object I can set the status code, and
>>> set
>>> the "entity" to the Java object I want to serialize.  As far as I can
>>> tell,
>>> I can't set the status code if I just return a java object.  What is the
>>> best strategy for returning an object AND setting the status code?  Is it
>>> just using the "Response" object as I described?
>>>
>>> --------------
>>> David M. Karr
>>> Senior Technical Architect, CDE Web Architecture
>>> ATT Consumer Digital Experience
>>> (425) 288-6027 work
>>> (206) 909-0664 cell
>>>
>>> This e-mail, and any attachments, are intended only for use by the
>>> addressee(s) named herein and may contain legally privileged and/or
>>> confidential information. It is the property of AT&T. If you are not the
>>> intended recipient of this email, you are hereby notified that any
>>> dissemination, distribution or copying of this email, any attachments
>>> thereto, and any use of the information contained is strictly prohibited.
>>> If you have received this email in error, please notify me at
>>> 425-288-6027and permanently delete the original and any copy thereof.
>>>
>>>
>>>
>>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com

Reply via email to