If you cannot use MTOM (which would do this automatically), then something 
similar to the LoggingInInterceptor is probably the correct approach.    I'd 
suggest using our CachedOutputStream.  It provides temp files for large 
messages, but uses byte[] for short messages to avoid file IO.   It also 
takes care of cleaning up the temp files and such.    Something like:


super(Phase.RECEIVE);

public void handleMessage(Message message) throws Fault {
     InputStream ins = message.getContent(InputStream.class);
     int threashold = 64 * 1024;  // <64K keep in memory
     CachedOutputStream fout = new CachedOutputStream(threashold);
     IOUtils.copy(ins, fout);
     fout.flush();
     message.setContent(InputStream.class, fout.getInputStream());
     fout.close();
     ins.close();
}
 

Dan

    


On Tuesday 16 December 2008 9:03:52 am Thomas Engelschmidt wrote:
> I'm implementing a cxf ws client, that's going to consume at huge amount of
> data (500gb a month). Since its not possible to restrict the response size.
>
> I would like to implement an interceptor, that gets the inputstream and
> redirects it to a file, and if possible returns another xml object instead.
> Since memory usage is the issue here. Therefor the interception, must
> happen during reception of response data.
> I have considered looking at the LoggingInInterceptor, but I'm not sure if
> it intercepts at the correct phase.
>
>
> 1) Is it possible to redirect input to a file using InInterceptors ?
>
> 2) Which phase should such FileInInterceptor use ?
>
> 3) Is it possible to inject another xml response, that gets unmarchalled
> into a jaxb pojo ?
>
> 4) Is this the right approach ?
>
> Cheers
>
> Thomas Engelschmidt



-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog

Reply via email to