问题
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