Hi

I think you can try returning a Response instead and set your
StreamingOutput impl as an entity and also set a Response type. The runtime
will default to application/octet-stream if no explicit @Produces is
available on the method, unless the method returns a Response...

cheers, Sergey

On Mon, Mar 8, 2010 at 5:48 PM, yong <[email protected]> wrote:

>
> Hi, I have been searching for an answer on this forum but didn't find any
> concrete suggestion.
>
> I have a restful service that would return a binary stream and the type can
> be PDF, XLS, etc so in this service I would like to be able to set the
> content-type dynamically. From what I read, I can use StreamingOutputImpl
> to
> write out the binary data but for some reason, I can't set the
> content-type:
>
> public StreamingOutput returnFile(HttpServletResponse hsr, String fileTag)
> {
> ...
>            hsr.setContentType(content.getContentType());
>            hsr.setContentLength((int) content.getContentLength());
>            hsr.setHeader("Content-Disposition", "inline;filename=" +
> content.getFileName());
> ...
>            return new StreamingOutputImp(content);
> }
>
> Apparently, hsr.setContentType doesn't work. content.getContentType()
> returns "application/pdf" but the client sees "application/octet-stream" so
> I guess it was overwritten by something.
>
> Did anyone run into this kind of questions? any suggestions on workaround
> would be appreciated. Thanks
>
> --
> View this message in context:
> http://old.nabble.com/Using-StreamingOutput---how-to-change-content-type-dynamically--tp27824908p27824908.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Reply via email to