-
1. Re: SAX Parse Exception on valid XML
dsteel100 Mar 20, 2014 6:52 AM (in response to dsteel100)OK, more information.
I have found that when my validation works, it is using the code from the JDK 1.7, but I think that when running within JBOSS it is using validation-api-1.0.0.GA-redhat-2.jar which has it's own implementation, and which is causing the exception.
I have tracked down that the issue resides with the Validator and what source it uses to validate.
If I retrieve an Element from the SOAP Message and use the following code:
DOMSource domSource = new DOMSource(requestElt);
validator.validate(domSource);
This fails in JBOSS but works with JDK 1.7
If I use
validator.validate(new StreamSource(new StringReader(getElementContent(requestElt))));
where
public static String getElementContent(Element message)
throws SOAPException, IOException {Document document = message.getOwnerDocument();
DOMImplementationLS domImplLS = (DOMImplementationLS) document
.getImplementation();
LSSerializer serializer = domImplLS.createLSSerializer();
return serializer.writeToString(message);
}This works both with JBOSS and JDK 1.7
The issue appears to be that the SOAP Message is UTF-16 rather than UTF-8
SO I have a solution that works, but has more lines of code to get there in both Oracle and JBOSS