The problem is that Strings can contain those illegal characters as discussed on Benson's blog. So to make sure that the produced XML is valid all Strings need to be filtered. Is it possible to do this filtering by CXF automagically before sending out the final XML?
Martijn On Fri, 2008-08-29 at 11:44 -0400, Daniel Kulp wrote: > Control characters like that are illegal in XML. You can read Benson's blog > about it: > http://dssheep.blogspot.com/2008/01/xml-10-versus-web-services.html > > Technically, I would consider this a bug in the JAXB marshaller as this > should > have thrown an exception at write time, not read time. If you turn on > schema validation on the send side, it might throw an exception, not really > sure. > > Dan > > > On Thursday 28 August 2008 6:01:00 pm Martijn Brinkers wrote: > > Hi, > > > > I use CXF as a soap server and CXF as a soap client. In one of my soap > > calls I return a String but sometimes this results in a > > WstxUnexpectedCharException. > > > > "WstxUnexpectedCharException: Illegal character ((CTRL-CHAR, code 27))" > > > > I read that a WstxUnexpectedCharException can be caused by a HTML server > > returning HTML content but that's not the case here. The string that's > > returned is returned by my CXF soap server. Shouldn't it be escaped or > > something? > > > > Thanks, > > > > Martijn Brinkers > > > > PS. I use CXF 2.1 > > > > > > > > Partial stacktrace > > > > Caused by: org.apache.cxf.interceptor.Fault: Unmarshalling Error: > > Illegal character ((CTRL-CHAR, code 27)) > > at [row,col {unknown-source}]: [7,1] > > at > > org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:6 > >42) at > > org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:5 > >55) at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64) at > > org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteral > >InInterceptor.java:102) at > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai > >n.java:221) at > > org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:429) at > > org.apache.cxf.transport.http.HTTPConduit > > $WrappedOutputStream.handleResponse(HTTPConduit.java:1988) > > at org.apache.cxf.transport.http.HTTPConduit > > $WrappedOutputStream.close(HTTPConduit.java:1824) > > at > > org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) > > at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:583) > > at org.apache.cxf.interceptor.MessageSenderInterceptor > > $MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java > >:62) at > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai > >n.java:221) at > > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276) > > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222) > > at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) > > at > > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:177) > > ... 111 more > > Caused by: javax.xml.bind.UnmarshalException > > - with linked exception: > > [com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character > > ((CTRL-CHAR, code 27)) > > at [row,col {unknown-source}]: [7,1]] > > at > > com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamExcep > >tion(UnmarshallerImpl.java:422) at > > com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unmars > >hallerImpl.java:360) at > > com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unmarsh > >allerImpl.java:337) at > > org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:6 > >28) ... 126 more > > Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal > > character ((CTRL-CHAR, code 27)) > > at [row,col {unknown-source}]: [7,1] > > at > > com.ctc.wstx.sr.StreamScanner.throwInvalidSpace(StreamScanner.java:650) > > at > > com.ctc.wstx.sr.BasicStreamReader.readTextSecondary(BasicStreamReader.java: > >4666) at > > com.ctc.wstx.sr.BasicStreamReader.readCoalescedText(BasicStreamReader.java: > >4124) at > > com.ctc.wstx.sr.BasicStreamReader.finishToken(BasicStreamReader.java:3699) > > at > > com.ctc.wstx.sr.BasicStreamReader.safeFinishToken(BasicStreamReader.java:36 > >47) at > > com.ctc.wstx.sr.BasicStreamReader.getTextCharacters(BasicStreamReader.java: > >830) at > > org.apache.cxf.staxutils.DepthXMLStreamReader.getTextCharacters(DepthXMLStr > >eamReader.java:159) at > > com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleCharacte > >rs(StAXStreamConnector.java:356) at > > com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStr > >eamConnector.java:220) at > > com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unmars > >hallerImpl.java:358) ... 128 more > > >
