CLONE -Exception in XML serialization causes malformed/corrupted response
-------------------------------------------------------------------------

                 Key: AXIS2-4124
                 URL: https://issues.apache.org/jira/browse/AXIS2-4124
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
          Components: kernel
    Affects Versions: 1.2, 1.1.1
         Environment: Windows Vista, Tomcat 5.5.20, JDK 1.5.0_10
            Reporter: Peter Storch
            Assignee: Glen Daniels
            Priority: Blocker
             Fix For: 1.3


Hi there,

We have a simple SOAP layer that returns data pulled from the DB using Axis.  
Nothing special here.

In our testing, one of the objects happened to have an invalid XML 1.0 
character (0x10) in its description field.  As it's not an application Fault 
(our application currently doesn't check for it.  It no doubt should, 
obviously), Axis2 wasn't aware of it until it's notified by the Woodstox 
BufferingXMLWriter of an invalid character (through IOException).  Axis2 caught 
the exception (at , and raised an AxisFault.  It then proceeded to send the 
Fault as its own message (envelope) back to the client.  All is well, except 
that Axis2 was in the middle of writing out response provided by the business 
application.  That led to a corrupted byte stream that contained a partial, not 
well-formed envelope, followed immediately by the Fault envelope.  Something to 
the effect of a purging (not flushing) to clear the output stream before 
sending out the Fault message would seem desirable.

It may not be so bad if the client receives such a corrupted stream, and throws 
some sort of error.  The Fault message becomes meaningless, obviously, which 
isn't great either.  But, what's worse is that the Axis2 client 
(ServiceClient.sendReceive) actually was able to parse the corrupted byte 
stream, and somehow considered the Fault message be the content of the last XML 
element that contained the invalid character.  Now, that's really bad.

This may have been logged in JIRA, but I couldn't seem to find it.

-Alan

Stack track of the exception caught by Axis2 during serialization:

 com.ctc.wstx.exc.WstxIOException: Invalid white space character (0x10) in text 
to output
        at 
com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:520)
        at 
org.apache.axiom.om.impl.llom.OMTextImpl.writeOutput(OMTextImpl.java:209)
        at 
org.apache.axiom.om.impl.llom.OMTextImpl.internalSerializeLocal(OMTextImpl.java:368)
        at 
org.apache.axiom.om.impl.llom.OMTextImpl.internalSerialize(OMTextImpl.java:197)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:766)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:750)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:766)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:750)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:766)
        at 
org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:564)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:750)
        at 
org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:551)
        at 
org.apache.axiom.om.impl.llom.OMSourcedElementImpl.serialize(OMSourcedElementImpl.java:592)
        at 
org.apache.axiom.om.impl.llom.OMElementImpl.toString(OMElementImpl.java:907)
        ... 30 more
Caused by: java.io.IOException: Invalid white space character (0x10) in text to 
output
        at com.ctc.wstx.sw.XmlWriter.throwInvalidChar(XmlWriter.java:545)
        at 
com.ctc.wstx.sw.BufferingXmlWriter.writeCharacters(BufferingXmlWriter.java:453)
        at 
com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:518)
        ... 43 more


This is the call stack from Eclipse debugger:

CoyoteOutputStream.write(byte[], int, int) line: 88     
UTF8Writer.flush() line: 96     
BufferingXmlWriter.flush() line: 214    
SimpleNsStreamWriter(BaseStreamWriter).flush() line: 311        
MTOMXMLStreamWriter.flush() line: 115   
SOAPEnvelopeImpl(OMNodeImpl).serializeAndConsume(OutputStream, OMOutputFormat) 
line: 419        
SOAPMessageFormatter.writeTo(MessageContext, OMOutputFormat, OutputStream, 
boolean) line: 55    
CommonsHTTPTransportSender.sendUsingOutputStream(MessageContext, 
OMOutputFormat) line: 275      
CommonsHTTPTransportSender.invoke(MessageContext) line: 203     
AxisEngine.sendFault(MessageContext) line: 533  
AxisServlet.handleFault(MessageContext, OutputStream, AxisFault) line: 393      
AxisServlet.processAxisFault(MessageContext, HttpServletResponse, OutputStream, 
AxisFault) line: 355    
AxisServlet.doPost(HttpServletRequest, HttpServletResponse) line: 152   
AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 
709     
AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 802     
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 
252      
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 173      
HibernateFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 95 
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 
202      
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 173      
StandardWrapperValve.invoke(Request, Response) line: 213        
StandardContextValve.invoke(Request, Response) line: 178        
StandardHostValve.invoke(Request, Response) line: 126   
ErrorReportValve.invoke(Request, Response) line: 105    
FastCommonAccessLogValve.invoke(Request, Response) line: 495    
StandardEngineValve.invoke(Request, Response) line: 107 
CoyoteAdapter.service(Request, Response) line: 148      
Http11Processor.process(InputStream, OutputStream) line: 869    
Http11Protocol$JmxHttp11ConnectionHandler(Http11BaseProtocol$Http11ConnectionHandler).processConnection(TcpConnection,
 Object[]) line: 664      
PoolTcpEndpoint.processSocket(Socket, TcpConnection, Object[]) line: 527        
LeaderFollowerWorkerThread.runIt(Object[]) line: 80     
ThreadPool$ControlRunnable.run() line: 684      
ThreadWithAttributes(Thread).run() line: 595    


What got sent over the wire back to the client:

<soapenv:Body 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><ns2:getSKUListResponse
 xmlns:ns2="http://mds.adserver.massive.com/xsd";><ns2:record><s41:createdOn 
xmlns:s41="http://types.mds.adserver.massive.com/";>2005-09-20T19:56:21.000Z</s41:createdOn><s42:description
 xmlns:s42="http://types.mds.adserver.massive.com/";>x</s42:description><s43:id 
xmlns:s43="http://types.mds.adserver.massive.com/";>51</s43:id><s44:modifiedOn 
xmlns:s44="http://types.mds.adserver.massive.com/";>2005-09-23T17:51:37.000Z</s44:modifiedOn><s45:name
 
xmlns:s45="http://types.mds.adserver.massive.com/";>EveryoneSKU</s45:name><s46:enabled
 
xmlns:s46="http://types.mds.adserver.massive.com/";>true</s46:enabled></ns2:record><ns2:record><s47:createdOn
 
xmlns:s47="http://types.mds.adserver.massive.com/";>2005-09-20T19:55:23.000Z</s47:createdOn><s48:description
 xmlns:s48="http://types.mds.adserver.massive.com/";><xml version='1.0' 
encoding='UTF-8'?><soapenv:Envelope><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>Invalid
 white space character (0x10) in text to output</faultstring><detail 
/></soapenv:Fault></soapenv:Body></soapenv:Envelope>


What the client (Axis2 ServiceClient) thought it was getting:

<soapenv:Body 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><ns2:getSKUListResponse
 xmlns:ns2="http://mds.adserver.massive.com/xsd";><ns2:record><s41:createdOn 
xmlns:s41="http://types.mds.adserver.massive.com/";>2005-09-20T19:56:21.000Z</s41:createdOn><s42:description
 xmlns:s42="http://types.mds.adserver.massive.com/";>x</s42:description><s43:id 
xmlns:s43="http://types.mds.adserver.massive.com/";>51</s43:id><s44:modifiedOn 
xmlns:s44="http://types.mds.adserver.massive.com/";>2005-09-23T17:51:37.000Z</s44:modifiedOn><s45:name
 
xmlns:s45="http://types.mds.adserver.massive.com/";>EveryoneSKU</s45:name><s46:enabled
 
xmlns:s46="http://types.mds.adserver.massive.com/";>true</s46:enabled></ns2:record><ns2:record><s47:createdOn
 
xmlns:s47="http://types.mds.adserver.massive.com/";>2005-09-20T19:55:23.000Z</s47:createdOn><s48:description
 xmlns:s48="http://types.mds.adserver.massive.com/";> version='1.0' 
encoding='UTF-8'?><soapenv:Envelope><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>Invalid
 white space character (0x10) in text to output</faultstring><detail 
/></soapenv:Fault></soapenv:Body></soapenv:Envelope></s48:description></ns2:record></ns2:getSKUListResponse></soapenv:Body>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to