javaw3ccdataaxiom

Axiom consistently divides huge CDATA block into several CDATA blocks


I faced with folowing problem I need to send XML message with one huge CDATA block via SOAP service.When AXIOM performs processing parameter it has consistently divide one large CDATA block into smaller blocks like this

How I can fix this?

try {
   String str = ""; // string which contains xml

   java.io.StringReader stringReader = new java.io.StringReader(str);
   javax.xml.stream.XMLInputFactory inputFactory = javax.xml.stream.XMLInputFactory.newInstance();
   inputFactory.setProperty(javax.xml.stream.XMLInputFactory.IS_COALESCING, false);   
   javax.xml.stream.XMLStreamReader streamReader = inputFactory.createXMLStreamReader(stringReader);      
   org.apache.axiom.om.impl.builder.StAXOMBuilder builder =
                                  new org.apache.axiom.om.impl.builder.StAXOMBuilder(streamReader);



       System.out.println("xml = " + builder.getDocumentElement());                                           
} catch (XMLStreamException e) {               
    e.printStackTrace();

After processing for test XML:

<ns1:customerData><![CDATA[<Root><Project><UserList><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User></UserList></Project></Root>]]></ns1:customerData>

will be

<ns1:customerData><![CDATA[....previous xml piece....]]><![CDATA[....previous xml piece....]]></ns1:customerData>

Solution

  • Assuming that you are using Woodstox as StAX implementation, you could try configuring the following property:

    inputFactory.setProperty("com.ctc.wstx.minTextSegment", 
                             Integer.valueOf(Integer.MAX_VALUE));