Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

README.txt

MuleSoft casenr: 00008941

1, In the case when the request contains CData elements there is an error indicating problems in ReversibleXMLStreamReader.
2, In the case when the request contains CData elements, the CData elements are not copied using XMLUtils

##############################
The request containing CData
##############################

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:add="http://www.w3.org/2005/08/addressing" xmlns:urn="urn:skl:tjanst1:rivtabp20">
   <soapenv:Header>
      <add:To>?</add:To>
   </soapenv:Header>
   <soapenv:Body>
      <urn:getProductDetailElem>
         <!--Optional:-->
         <productId><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soapenv:Body><int:test/></soapenv:Body></soapenv:Envelope>]]></productId>
      </urn:getProductDetailElem>
   </soapenv:Body>
</soapenv:Envelope>

########################
The error occuring in log pointing at ReversibleXMLStreamReader
########################

INFO  2013-09-16 13:46:02,896 [[cdatatest-reversiblexmlstreamreader].connector.http.mule.default.receiver.02] org.mule.component.simple.LogComponent: 
********************************************************************************
* Message received in service: cdatatest-flow. Content is: '[Message could     *
* not be converted to string]'                                                 *
********************************************************************************
WARN  2013-09-16 13:46:02,974 [[cdatatest-reversiblexmlstreamreader].connector.http.mule.default.receiver.02] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {urn:skl:tjanst1:rivtabp20}Tjanst1Service has thrown exception, unwinding now
java.lang.ClassCastException: javanet.staxutils.events.CDataEvent cannot be cast to javanet.staxutils.events.CharactersEvent
	at org.mule.module.xml.stax.ReversibleXMLStreamReader.getText(ReversibleXMLStreamReader.java:583)
	at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:541)
	at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:513)
	at org.mule.module.cxf.support.OutputPayloadInterceptor$1.write(OutputPayloadInterceptor.java:83)
	at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:127)
	at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:117)
	at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:113)
	at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:119)
	at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
	at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:232)
	at org.mule.module.cxf.CxfInboundMessageProcessor$1.write(CxfInboundMessageProcessor.java:373)
	at org.mule.transport.http.HttpServerConnection.writeResponse(HttpServerConnection.java:351)
	at org.mule.transport.http.HttpMessageProcessTemplate.sendResponseToClient(HttpMessageProcessTemplate.java:176)
	at org.mule.execution.FlowProcessingPhase$1.run(FlowProcessingPhase.java:82)
	at org.mule.work.WorkerContext.run(WorkerContext.java:311)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)


##############################################################
The fix in org.mule.module.xml.stax.ReversibleXMLStreamReader
#############################################################

In org.mule.module.xml.stax.ReversibleXMLStreamReader, line 584-589 is changed:

public String getText()
    {
        if (replay)
        {
            if (current instanceof CommentEvent)
            {
                return ((CommentEvent) current).getText();
            }
            else
            {
                //#####################################################################
                //FIX for case 00008941, CData not handled in ReversibleXMLStreamReader
                //#####################################################################
                return ((AbstractCharactersEvent) current).getData();
                //return ((CharactersEvent) current).getData();
                //#####################################################################
            }
        }
        else
        {
            return super.getText();
        }
}

##############################################################
The fix in org.mule.module.xml.util.XMLUtils
#############################################################

In org.mule.module.xml.util.XMLUtils, line 468-474 is changed:

 public static void copy(XMLStreamReader reader, XMLStreamWriter writer,
                            boolean fragment) throws XMLStreamException {
        // number of elements read in
        int read = 0;
        int event = reader.getEventType();

        while (reader.hasNext()) {
            switch (event) {
            case XMLStreamConstants.START_ELEMENT:
                read++;
                writeStartElement(reader, writer);
                break;
            case XMLStreamConstants.END_ELEMENT:
                writer.writeEndElement();
                read--;
                if (read <= 0 && !fragment) {
                    return;
                }
                break;
            case XMLStreamConstants.CHARACTERS:
                writer.writeCharacters(reader.getText());
                break;
            //######################################################
            //FIX for case 00008941, CData not handled in XMLUtils.copy
            //######################################################
            case XMLStreamConstants.CDATA:
                writer.writeCData(reader.getText());
                break;
            //######################################################
            case XMLStreamConstants.START_DOCUMENT:
            case XMLStreamConstants.END_DOCUMENT:
            case XMLStreamConstants.ATTRIBUTE:
            case XMLStreamConstants.NAMESPACE:
                break;
            default:
                break;
            }
            event = reader.next();
        }
    }

############################################
Apply the patch
############################################

Apply the patches-mule-3.3.1-fix-cdata-MULE-8941-1.0.jar in the <MULE_HOME>/lib/user folder and restart mule.

Verify by using a request containing CData elements.

About

No description or website provided.

Topics

Resources

Packages

No packages published

Languages

You can’t perform that action at this time.