Finally, I fixed this problem.
The reason causes this problem is the JDK6 XMLStreamReader implementation's bug, as this topic said.
How to fix it?
I read the XFire's source code ,the answer is in this code:
XMLStreamReader reader =
STAXUtils.createXMLStreamReader(request.getInputStream(),
charEncoding,
context);
The STAXUtils.createXMLStreamReader will create XMLInputFactory to generate XMLStreamReader.
public static XMLInputFactory getXMLInputFactory(MessageContext ctx)
{
if (ctx == null) return xmlInputFactory;
Object inFactoryObj = ctx.getContextualProperty(XFire.STAX_INPUT_FACTORY);
if (inFactoryObj instanceof XMLInputFactory)
{
return (XMLInputFactory) inFactoryObj;
}
else if (inFactoryObj instanceof String)
{
String inFactory = (String) inFactoryObj;
XMLInputFactory xif = (XMLInputFactory) factories.get(inFactory);
if (xif == null)
{
xif = (XMLInputFactory) createFactory(inFactory, ctx);
configureFactory(xif,ctx);
factories.put(inFactory, xif);
}
return xif;
}
if(!inFactoryConfigured){
configureFactory(xmlInputFactory,ctx);
inFactoryConfigured=true;
}
return xmlInputFactory;
}
In this code, you can configure "xfire.stax.input.factory" XFire properties to generate XMLInputFactory whose XMLStreamReader has no bug, However, I can't figure out how to set this properties.
And in my project, xmlInputFactory is ths default xmlInputFactory which is JDK's.
/**
* Create a new instance of the factory.
* This static method creates a new factory instance.
* This method uses the following ordered lookup procedure to determine
* the XMLInputFactory implementation class to load:
* Use the javax.xml.stream.XMLInputFactory system property.
* Use the properties file "lib/stax.properties" in the JRE directory.
* This configuration file is in standard java.util.Properties format and contains
* the fully qualified name of the implementation class with the key being the system property defined above.
* Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
* The Services API will look for a classname in the file META-INF/services/javax.xml.stream.XMLInputFactory
* in jars available to the runtime.
* Platform default XMLInputFactory instance.
* Once an application has obtained a reference to a XMLInputFactory
* it can use the factory to configure and obtain stream instances.
*
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded
*/
public static XMLInputFactory newInstance()
throws FactoryConfigurationError
{
return (XMLInputFactory) FactoryFinder.find(
"javax.xml.stream.XMLInputFactory",
"com.sun.xml.internal.stream.XMLInputFactoryImpl");
}
So, you can Use the javax.xml.stream.XMLInputFactory system property to use another XMLInputFactroy, such as wstx lib.