|
From: Gregor J. <gr...@ja...> - 2013-06-20 15:35:11
|
Although this might appear to you like a stupid question, it is not meant to waste anyone's time - so why are you bother answering if you don't include any helpful information?
I might misuse the concept of OutputStream here - if so, I'd be happy to learn more about it.
IMO, fetching a stream from one resource and routing it through to serve another one is a legitimate use case.
----- Original Message -----
From: "Bill Burke" <bb...@re...>
To: res...@li...
Sent: Thursday, June 20, 2013 4:10:09 PM
Subject: Re: [Resteasy-developers] Unable to fetch StreamingOutput via Client Api
Of course you can't obtain a StreamingOutput from the client api....
On 6/20/2013 7:14 AM, Gregor Jarisch wrote:
> Hi,
>
> I have to proxy a request from one Jax-RS resource to another (secured) one.
>
> RestInterface {
>
> @GET
> @Path("/{id}")
> @Produces({"image/jpeg"})
> public StreamingOutput getImage(@PathParam("id") String id);
>
> }
>
> RestProxyInterface {
>
> @GET
> @Path("/{id}")
> @Produces({"image/jpeg"})
> public StreamingOutput getImage(@PathParam("id") String id){
> // create client proxy ... --> remoteRestInterface
> StreamingOutput image = remoteRestInterface.getImage(id);
> return image;
> }
> }
>
> Client api causes following exception:
> Caused by: javax.ws.rs.ProcessingException: Unable to find a MessageBodyReader of content-type image/jpeg and type interface javax.ws.rs.core.StreamingOutput
> at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:39)
> at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:73)
> at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:50)
> at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59)
> at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
> at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:244)
> at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:178)
> at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:211)
> at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:104)
> ... 35 more
>
> So, obviously there is no reader for StreamingOutput.
> Creating on:
>
> @Provider
> @Consumes("image/jpeg")
> public class StreamingOutputReader implements MessageBodyReader<StreamingOutput> {
> @Override
> public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
> return StreamingOutput.class.isAssignableFrom(type);
> }
>
> @Override
> public StreamingOutput readFrom(Class<StreamingOutput> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException, WebApplicationException {
> return new StreamingOutput() {
> @Override
> public void write(OutputStream output) throws IOException, WebApplicationException {
> byte[] buffer = new byte[1024];
> int bytesRead;
> while ((bytesRead = entityStream.read(buffer)) != -1) {
> output.write(buffer, 0, bytesRead);
> }
> }
> };
> }
> }
>
> Unfortunately I cannot get it to be invoked by the Client Api. Scanning providers is on and according to the logs it is recognized by resteasy.. Debugging through the code, indeed the providerFactory of ClientReaderInterceptorContext doesn't have my StreamingOutputReader...
>
> What am I doing wrong here?
>
> Thanks,
>
> Gregor
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> Resteasy-developers mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
>
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Resteasy-developers mailing list
Res...@li...
https://lists.sourceforge.net/lists/listinfo/resteasy-developers
|