You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by David Karlsen <da...@gmail.com> on 2011/11/17 14:29:44 UTC

Obtaining the raw request and response to my services as Strings or streams

I do this to retrieve the request and response to/from my service:

final InputStream inputStream =
message.getExchange().getInMessage().getContent( InputStream.class );
                inputStream.reset();

                CacheAndWriteOutputStream cachedOutputStream =
(CacheAndWriteOutputStream)
message.getExchange().getOutMessage().getContent( OutputStream.class
);


this used to work - but somewhere in the line it started to fail with:
java.lang.ClassCastException:
org.apache.cxf.transport.http.AbstractHTTPDestination$WrappedOutputStream
incompatible with org.apache.cxf.io.CacheAndWriteOutputStream
        at xxx.MyInterceptor.handleMessage


AbstractHTTPDestination$WrappedOutputStream is not available outside the class.
AbstractWrappedOutputStream does not provide a getInputStream() method.

Please advice me how to obtain the requests/responses either as a
stream or as a String.

Is my current approach OK?

--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Re: Obtaining the raw request and response to my services as Strings or streams

Posted by Daniel Kulp <dk...@apache.org>.
The best bet is to take a look at the source for the Logging interceptors and 
see what they are doing.     Maybe use those as a start.

Dan


On Thursday, November 17, 2011 2:29:44 PM David Karlsen wrote:
> I do this to retrieve the request and response to/from my service:
> 
> final InputStream inputStream =
> message.getExchange().getInMessage().getContent( InputStream.class );
>                 inputStream.reset();
> 
>                 CacheAndWriteOutputStream cachedOutputStream =
> (CacheAndWriteOutputStream)
> message.getExchange().getOutMessage().getContent( OutputStream.class
> );
> 
> 
> this used to work - but somewhere in the line it started to fail with:
> java.lang.ClassCastException:
> org.apache.cxf.transport.http.AbstractHTTPDestination$WrappedOutputStream
> incompatible with org.apache.cxf.io.CacheAndWriteOutputStream
>         at xxx.MyInterceptor.handleMessage
> 
> 
> AbstractHTTPDestination$WrappedOutputStream is not available outside the
> class. AbstractWrappedOutputStream does not provide a getInputStream()
> method.
> 
> Please advice me how to obtain the requests/responses either as a
> stream or as a String.
> 
> Is my current approach OK?
> 
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: Obtaining the raw request and response to my services as Strings or streams

Posted by David Karlsen <da...@gmail.com>.
Anybody?

2011/11/17 David Karlsen <da...@gmail.com>:
> I do this to retrieve the request and response to/from my service:
>
> final InputStream inputStream =
> message.getExchange().getInMessage().getContent( InputStream.class );
>                inputStream.reset();
>
>                CacheAndWriteOutputStream cachedOutputStream =
> (CacheAndWriteOutputStream)
> message.getExchange().getOutMessage().getContent( OutputStream.class
> );
>
>
> this used to work - but somewhere in the line it started to fail with:
> java.lang.ClassCastException:
> org.apache.cxf.transport.http.AbstractHTTPDestination$WrappedOutputStream
> incompatible with org.apache.cxf.io.CacheAndWriteOutputStream
>        at xxx.MyInterceptor.handleMessage
>
>
> AbstractHTTPDestination$WrappedOutputStream is not available outside the class.
> AbstractWrappedOutputStream does not provide a getInputStream() method.
>
> Please advice me how to obtain the requests/responses either as a
> stream or as a String.
>
> Is my current approach OK?
>
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
>



-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen