org.codehaus.xfire.fault.XFireFault: Could not read XML stream.. Nested exception is javax.xml.strea

前端之家收集整理的这篇文章主要介绍了org.codehaus.xfire.fault.XFireFault: Could not read XML stream.. Nested exception is javax.xml.strea前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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,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,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,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目录下。

猜你在找的XML相关文章