> I'm guessing that > the reason for this is that CXF is writing the response directly to the > output stream.
Yep. For performance, that's important, but it does kind of assume the data that is being written is correct. > 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. Dan On Friday 19 March 2010 3:47:37 pm Christie, Marc wrote: > At work, we've run into the "invalid white space characters in text > to output" problem. I've been able to deal with these characters using > the wrapped XMLStreamWriter idea in this discussion: > http://old.nabble.com/WSS4JOutInterceptor-and-%22Invalid-white-space-cha > racter-%280x1%29-in-text--to-output%22-td26675746.html > > However, there is one nagging concern. While writing the response, when > the invalid white space character was encountered, CXF dumped a Fault > message directly in the response it was writing and returned. We're > using CXF 2.1.9 and we get something like this as a response: > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Body> > <ns1:getResponse > xmlns:ns1="http://mycompany.com/webservices/MyService"> > <ns1:data> > <ns2:info > xmlns:ns2="http://info.mycompany.com"> > <ns2:name>ABC</ns2:name> > <ns2:detail> > <soap:Fault> > <faultcode>soap:Server</faultcode> > <faultstring>org.apache.cxf.aegis.DatabindingException: > Error writing document.. Nested exception is > com.ctc.wstx.exc.WstxIOException: Invalid white space > character > (0xb) in text to output</faultstring> > </soap:Fault> > </ns2:detail> > </ns2:info> > </ns1:data> > </ns1:getResponse> > </soap:Body> > </soap:Envelope> > > The HTTP status is 200. There is no way for a service client to know > that something went wrong, except perhaps to do a deep inspection of the > message. Also, the response isn't a valid response. I'm guessing that > the reason for this is that CXF is writing the response directly to the > output stream. Is there a way to configure CXF so that it writes and > validates the response in memory before writing to the output stream? > > Thanks, > > Marc -- Daniel Kulp [email protected] http://dankulp.com/blog
