You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by tutu <tu...@gmail.com> on 2009/07/01 18:46:56 UTC
RESTFUL Web service returning Image
Hi,
I'm trying to create a REST web service that returns an image. Is there an
easy way to do that?
I already hava REST web services that return json:
my xml file:
<jaxrs:server id="restServices" address="/">
<jaxrs:serviceBeans>
<ref bean="serviceImpl" />
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
</jaxrs:server>
and in my class:
@Produces("application/json" )
public class ServiceImpl {
@GET
@Path("/getCategories")
public Categories getCategories() {
...
}
}
Is there a way to have any web service that returns an image instead of
json?
Regards,
Tugdual
--
View this message in context: http://www.nabble.com/RESTFUL-Web-service-returning-Image-tp24293230p24293230.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: RESTFUL Web service returning Image
Posted by Sergey Beryozkin <se...@iona.com>.
Hi
Perhaps you might want to have a method which returns say java awt image and
have @Produces("image/gif") (or whatever the right media type is) on that
method ? There's no default support for serializing Images (perhaps we
should do some work here) so you'll also need to register a message body
writer. Simpler option would likely be returning JAX-RS StreamingOutput
implementation which will help the runtime to write it efficiently... You
can also return File/byte[]/InputStream representing this image
cheers, Sergey
tutu wrote:
>
> Hi,
>
> I'm trying to create a REST web service that returns an image. Is there an
> easy way to do that?
>
> I already hava REST web services that return json:
> my xml file:
> <jaxrs:server id="restServices" address="/">
> <jaxrs:serviceBeans>
> <ref bean="serviceImpl" />
> </jaxrs:serviceBeans>
> <jaxrs:extensionMappings>
> <entry key="json" value="application/json" />
> </jaxrs:extensionMappings>
> </jaxrs:server>
>
> and in my class:
>
> @Produces("application/json" )
> public class ServiceImpl {
>
> @GET
> @Path("/getCategories")
> public Categories getCategories() {
> ...
> }
> }
>
> Is there a way to have any web service that returns an image instead of
> json?
>
> Regards,
>
> Tugdual
>
>
>
--
View this message in context: http://www.nabble.com/RESTFUL-Web-service-returning-Image-tp24293230p24306846.html
Sent from the cxf-user mailing list archive at Nabble.com.