Web service response contains an invalid XML character

你说的曾经没有我的故事 提交于 2019-12-07 12:14:51

问题


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.

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 ?


回答1:


"My application is connecting to a web service rpc/encoded."

That's the catch. The service is "rpc/encoded" which is non-WS-I-compliant. The developers decided after some heated discussion sometime in the past not to 'fix' this error.




回答2:


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.

To create your own LogHandler

The method to search and destroy illegal characters

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()))); ... }



来源:https://stackoverflow.com/questions/12697323/web-service-response-contains-an-invalid-xml-character

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!