Axiom 一致地将巨大的 CDATA 块分成几个 CDATA 块
Axiom consistently divides huge CDATA block into several CDATA blocks
我面临以下问题我需要通过 SOAP 发送带有一个巨大 CDATA 块的 XML 消息 service.When AXIOM 执行处理参数它一直将一个大 CDATA 块分成像这样的小块
我该如何解决这个问题?
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();
测试处理后 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>
将会
<ns1:customerData><![CDATA[....previous xml piece....]]><![CDATA[....previous xml piece....]]></ns1:customerData>
假设您使用 Woodstox 作为 StAX 实现,您可以尝试配置以下 属性:
inputFactory.setProperty("com.ctc.wstx.minTextSegment",
Integer.valueOf(Integer.MAX_VALUE));
我面临以下问题我需要通过 SOAP 发送带有一个巨大 CDATA 块的 XML 消息 service.When AXIOM 执行处理参数它一直将一个大 CDATA 块分成像这样的小块
我该如何解决这个问题?
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();
测试处理后 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>
将会
<ns1:customerData><![CDATA[....previous xml piece....]]><![CDATA[....previous xml piece....]]></ns1:customerData>
假设您使用 Woodstox 作为 StAX 实现,您可以尝试配置以下 属性:
inputFactory.setProperty("com.ctc.wstx.minTextSegment",
Integer.valueOf(Integer.MAX_VALUE));