1 Reply Latest reply on Mar 20, 2014 6:52 AM by dsteel100

    SAX Parse Exception on valid XML

    dsteel100 Newbie

      I have a jar that validates a SOAP message against a WSDL.  When I test the JAR library stand alone in NETBEANS the JUNIT test passes correctly for the SOAP message and WSDL.  When I use it for real in Glassfish and Web Logic it passes successfully.  When I call the method from within JBOSS EAP 6.1.0.GA, I get the error null: org.xml.sax.SAXParseException; cvc-complex-type.3.2.2: Attribute 'XXX' is not allowed to appear in element 'YYY'


      Attrribute 'XXX' is marked as an optional attribute to the element 'YYY'


      Therefore, why is the same code not working when called from JBOSS?


      Many thanks, as I am pulling my hair out.

        • 1. Re: SAX Parse Exception on valid XML
          dsteel100 Newbie

          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);



          This fails in JBOSS but works with JDK 1.7


          If I use


               validator.validate(new StreamSource(new StringReader(getElementContent(requestElt))));




              public static String getElementContent(Element message)
                      throws SOAPException, IOException {

                  Document document = message.getOwnerDocument();
                  DOMImplementationLS domImplLS = (DOMImplementationLS) document
                  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