版权声明:转载请注明出处 https://blog.csdn.net/seashouwang/article/details/24014669
xfire使用中出现故障:
1.
[2014-04-16 14:51:07.564]-[ERROR] org.apache.struts2.dispatcher.Dispatcher Exception occurred during processing request: Could not read XML stream.. Nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,648]
Message: elementGetText() function expects text only elment but START_ELEMENT was encountered.
org.codehaus.xfire.fault.XFireFault: Could not read XML stream.. Nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,648]
Message: elementGetText() function expects text only elment but START_ELEMENT was encountered.
at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
Caused by: org.codehaus.xfire.XFireRuntimeException: Could not read XML stream.. Nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,648]
Message: elementGetText() function expects text only elment but START_ELEMENT was encountered.
at org.codehaus.xfire.aegis.stax.ElementReader.getValue(ElementReader.java:128)
at org.codehaus.xfire.aegis.type.basic.StringType.readObject(StringType.java:21)
at org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:159)
at org.codehaus.xfire.aegis.type.basic.ArrayType.readCollection(ArrayType.java:80)
at org.codehaus.xfire.aegis.type.collection.CollectionType.readObject(CollectionType.java:36)
at org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:169)
at org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206)
at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:51)
at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
... 82 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,648]
Message: elementGetText() function expects text only elment but START_ELEMENT was encountered.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.getElementText(XMLStreamReaderImpl.java:851)
at org.codehaus.xfire.util.stax.DepthXMLStreamReader.getElementText(DepthXMLStreamReader.java:86)
at org.codehaus.xfire.util.stax.DepthXMLStreamReader.getElementText(DepthXMLStreamReader.java:86)
at org.codehaus.xfire.aegis.stax.ElementReader.getValue(ElementReader.java:122)
... 92 more
2.
Caused by: org.codehaus.xfire.XFireRuntimeException: Could not read XML stream..
Nested exception is com.ctc.wstx.exc.WstxParsingException: Expected a text token, got START_ELEMENT.
问题描写叙述:以上是导入文本件出现错误信息,使用的是字符流进行读取文件,在action层做了对应的处理特殊字符,在传输到service是出现不能解析。
1.
[2014-04-16 14:51:07.564]-[ERROR] org.apache.struts2.dispatcher.Dispatcher Exception occurred during processing request: Could not read XML stream.. Nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,648]
Message: elementGetText() function expects text only elment but START_ELEMENT was encountered.
org.codehaus.xfire.fault.XFireFault: Could not read XML stream.. Nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,648]
Message: elementGetText() function expects text only elment but START_ELEMENT was encountered.
at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
Caused by: org.codehaus.xfire.XFireRuntimeException: Could not read XML stream.. Nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,648]
Message: elementGetText() function expects text only elment but START_ELEMENT was encountered.
at org.codehaus.xfire.aegis.stax.ElementReader.getValue(ElementReader.java:128)
at org.codehaus.xfire.aegis.type.basic.StringType.readObject(StringType.java:21)
at org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:159)
at org.codehaus.xfire.aegis.type.basic.ArrayType.readCollection(ArrayType.java:80)
at org.codehaus.xfire.aegis.type.collection.CollectionType.readObject(CollectionType.java:36)
at org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:169)
at org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206)
at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:51)
at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
... 82 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,648]
Message: elementGetText() function expects text only elment but START_ELEMENT was encountered.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.getElementText(XMLStreamReaderImpl.java:851)
at org.codehaus.xfire.util.stax.DepthXMLStreamReader.getElementText(DepthXMLStreamReader.java:86)
at org.codehaus.xfire.util.stax.DepthXMLStreamReader.getElementText(DepthXMLStreamReader.java:86)
at org.codehaus.xfire.aegis.stax.ElementReader.getValue(ElementReader.java:122)
... 92 more
2.
Caused by: org.codehaus.xfire.XFireRuntimeException: Could not read XML stream..
Nested exception is com.ctc.wstx.exc.WstxParsingException: Expected a text token, got START_ELEMENT.
问题描写叙述:以上是导入文本件出现错误信息,使用的是字符流进行读取文件,在action层做了对应的处理特殊字符,在传输到service是出现不能解析。
看了网上非常多人提出的jdk问题。冲突问题等解决的方法,都试过没有一个能够。
最后找到一个网友的解决的方法最可行。就是改动wstx.jar文件。
解决方法:以上问题主要是在传输文本或者xml过程中出现特殊字符,xfire公布的webservice中不能解析一下特殊字符,比方&,¥,{},<>等或者是编码问题。使用统一编码格式传递參数。
将xfire中的wstx-asl-3.2.9.jar包中BaseStreamWriter类中的方法处理xml部分进行改动,加上处理特殊字符就可以解决这个问题。
以上解决方式来自于博客园以为网友提供的解决方式。非常感谢该网友提供的帮助。该网友提供的解决方式例如以下:
1.改动wstx-asl-3.2.9.jar包中BaseStreamWriter类。
至于改动的文件本人一起上传到资源。希望对遇到此问题的朋友一个小小的帮助。
2.用法:能够直接使用wstx-asl-3.2.9.jar包,改包中已经包括被改动的文件。或者使用BaseStreamWriter源文件放在src文件夹下。