cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christie, Marc" <>
Subject RE: CXF fault while streaming response
Date Mon, 22 Mar 2010 15:44:26 GMT
-----Original Message-----
From: Daniel Kulp [] 
Sent: Friday, March 19, 2010 11:06 PM
Cc: Christie, Marc
Subject: Re: CXF fault while streaming response

>> Is there a way to configure CXF so that it writes and
>> validates the response in memory before writing to the output stream?

> Well, for some cases, you could add something like the
> which would "write" the output to the SAAJ model first, then to the
> stream.  Not sure if it would catch this particular case though as the
> model may be OK with the invalid string.   You could also turn on
> validation which does buffering as well.

Thanks Dan. I tried the SAAJOutInterceptor approach, but as you
suspected it didn't catch this particular case. I end up getting this
stack trace:
com.ctc.wstx.exc.WstxIOException: Invalid white space character (0xb) in
text to output
	at org.apache.cxf.staxutils.StaxUtils.copy(
	at org.apache.cxf.staxutils.StaxUtils.copy(

It copies the SOAPMessage.getSOAPPart() to the XMLStreamWriter for the
response. Since it is copying directly to the response output stream,
the fault that gets generated gets dumped in the middle of the SOAP
body, like before.

I also tried turning on schema validation. It still fails in the same
place, in the BareOutInterceptor. We're doing java first development, so
I don't know if that has any bearing on the ability to validate a
response; I don't know if CXF needs to have a WSDL to validate the

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.
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?



View raw message