On Monday 22 March 2010 11:44:26 am Christie, Marc wrote:
> I'm thinking that one approach to this problem is to create an
> interceptor to swap out the XMLStreamWriter with a buffering one that
> writes to some sort of buffer (i.e., StaxUtils.createXMLStreamWriter(new
> ByteArrayOutputStream())), then have it also set up an ending
> interceptor that would copy the buffer to the original XMLStreamWriter.
Well, it would be better to just replace the OutputStream with a
CachedOutputStream before the StaxInInterceptor and then in an ending
interceptor or in a listener on the CachedOutputStream (most likely the
listener onClose method would work best), write the contents of the cached
stream to the original stream. This is similar to how the logging works.
The interceptors handleFault method would restore the original Stream and
would probably have to clear a couple flags on the message that the SOAP
interceptors leave there.
message.remove(SoapOutInterceptor.WROTE_ENVELOPE_START);
might be enough.
Dan
> That way, writes to the buffer that generate an exception, like with the
> invalid whitespace character, could be handled before actually writing
> anything to the response output stream. Does this sound reasonable? Are
> there any other approaches I should consider?
>
> Thanks,
>
> Marc
--
Daniel Kulp
[email protected]
http://dankulp.com/blog