Web服务响应包含无效的XML字符 [英] Web service response contains an invalid XML character

查看:256
本文介绍了Web服务响应包含无效的XML字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序正在连接到rpc/已编码的Web服务.我正在使用Axis 1.4. 当Web服务发送响应时,它发送一个无效字符,然后发送一个异常:

My application is connecting to a web service rpc/encoded. Im using Axis 1.4. When the webservice sends a response, it sends an invalid character then an exception:

http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: 
  An invalid XML character (Unicode: 0x3) was found in the element content of the document.

xml编码为"ISO-8859-1".我认为这是问题所在.

The xml encoding is "ISO-8859-1". I think that is the problem.

我的问题是:我可以在应用程序中进行任何配置以接受此无效字符吗?

My question is: Is there any configuration that i can make in my application to accept this invalid character ?

推荐答案

我解决了在org.apache.axis.handlers.LogHandler内放置一个方法来搜索和销毁非法字符,然后解析前面的xml响应中的内容的问题.

I solved the problem putting a method inside org.apache.axis.handlers.LogHandler to search and destroy illegal characters before parse the the content inside xml response ahead.

创建自己的LogHandler

搜索和销毁方法非法字符

新LogHandler的内部logMessages方法中放置以下内容: private void logMessages(MessageContext msgContext) throws AxisFault { ... msgContext.setResponseMessage(new Message( stripNonValidXMLCharacters(((Message) msgContext .getResponseMessage()).getSOAPPartAsString()))); ... }

Inside logMessages method of your new LogHandler put the following: private void logMessages(MessageContext msgContext) throws AxisFault { ... msgContext.setResponseMessage(new Message( stripNonValidXMLCharacters(((Message) msgContext .getResponseMessage()).getSOAPPartAsString()))); ... }

这篇关于Web服务响应包含无效的XML字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆