You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Olivier <ol...@mutantzoo.com> on 2008/05/20 08:28:56 UTC

Message Body Providers for Java types?

Is it possible to return an int, Integer or List objects on a JAX-RS 
@GET method?

I am getting the following error in the browser (example here with 
ArrayList):

.No message body writer found for response class : ArrayList.

Thanks

Olivier

Re: Message Body Providers for Java types?

Posted by Olivier <ol...@mutantzoo.com>.
Sergey,

Thanks. Would be nice to treat output the same way than the WS stack in 
CXF, using Aegis or JAXB for instance, no. One could have cntrol with 
JAXB annotation on the output of a specific object at the 
attribute/element level.
Handling primitive types and Collections would be great!

Olivier

Sergey Beryozkin wrote:
> Hi
>
> No primitive types (or their object equivalents) are supported on the output
> by default, this is per JAX-RS spec, but nothing prevents a user from
> creating a custom writer, have a look please at a sample code for a Long
> writer at http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html.
>
> The reason is that it's not clear how a default writer should serialize say
> a given Long or List value if, say, an application/xml format is produced. I
> have some ideas how to deal with collections/maps on the output if
> application/xml is requested, and perhaps we may provide a writer for
> primitive types but only if text/plain is requested
>
> On input, primitive types are supported, but not collections. I believe the
> later version of the spec also mandates a support for collections if they're
> mapped to queries...
>
> Also, yes is the answer to your other question about supporting subresources
> exposed as interfaces in a root class... 
>
> Cheers, Sergey
>
>
> Olivier Brand wrote:
>   
>> Is it possible to return an int, Integer or List objects on a JAX-RS 
>> @GET method?
>>
>> I am getting the following error in the browser (example here with 
>> ArrayList):
>>
>> .No message body writer found for response class : ArrayList.
>>
>> Thanks
>>
>> Olivier
>>
>>
>>     
>
>   


Re: Message Body Providers for Java types?

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

No primitive types (or their object equivalents) are supported on the output
by default, this is per JAX-RS spec, but nothing prevents a user from
creating a custom writer, have a look please at a sample code for a Long
writer at http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html.

The reason is that it's not clear how a default writer should serialize say
a given Long or List value if, say, an application/xml format is produced. I
have some ideas how to deal with collections/maps on the output if
application/xml is requested, and perhaps we may provide a writer for
primitive types but only if text/plain is requested

On input, primitive types are supported, but not collections. I believe the
later version of the spec also mandates a support for collections if they're
mapped to queries...

Also, yes is the answer to your other question about supporting subresources
exposed as interfaces in a root class... 

Cheers, Sergey


Olivier Brand wrote:
> 
> Is it possible to return an int, Integer or List objects on a JAX-RS 
> @GET method?
> 
> I am getting the following error in the browser (example here with 
> ArrayList):
> 
> .No message body writer found for response class : ArrayList.
> 
> Thanks
> 
> Olivier
> 
> 

-- 
View this message in context: http://www.nabble.com/Message-Body-Providers-for-Java-types--tp17334084p17342174.html
Sent from the cxf-user mailing list archive at Nabble.com.