cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christie, Marc" <mchris...@walkerinfo.com>
Subject RE: CXF fault while streaming response
Date Mon, 22 Mar 2010 15:44:26 GMT
-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Friday, March 19, 2010 11:06 PM
To: users@cxf.apache.org
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
SAAJOutInterceptor 
> which would "write" the output to the SAAJ model first, then to the
output 
> stream.  Not sure if it would catch this particular case though as the
SAAJ 
> model may be OK with the invalid string.   You could also turn on
schema 
> 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
com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:5
11)
	at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:425)
	at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:403)
	at
org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor$SAAJOutEndingInterce
ptor.handleMessage(SAAJOutInterceptor.java:176)
	at
org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor$SAAJOutEndingInterce
ptor.handleMessage(SAAJOutInterceptor.java:141)
...

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

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?

Thanks,

Marc



Mime
View raw message