Code:
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(new File("echo.xsd"));
Validator validator = schema.newValidator();
validator.validate(new StreamSource(new File("payload.xml")));
Here i'm validating against my echo.xsd from my web service. The response is:
Code:
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope'.
at com.sun.org.apache.xerces.internal.jaxp.validation.Util.toSAXParseException(Unknown Source)
I can understand that in that way, that i define my message types but i doesn't define the soap envelop. That's why he doesn't know the "Envelope" tag.
If i use the soap envelope schema(not my echo.xsd), it's not working.
The response is:
Code:
org.xml.sax.SAXParseException: cvc-elt.4.2: Cannot resolve 'ns2:
AddressDataType' to a type definition for element 'ns2:casDataType'.
at com.sun.org.apache.xerces.internal.jaxp.validation.Util.toSAXParseException(Unknown Source)
Ok, that's also clear. The soap-envelope schema doesn't contain my message types.
But if i use that tool (https://msv.dev.java.net) to validate against the soap envelope schema, it's says that my document is valid.
And if i use that tool to validate my payload against my echo.xsd schema, i get this response(not valid):
Code:
Error at line:3, column:61 of file:///C:/download/msv-20060319/payload.xml
tag name "SOAP-ENV:Envelope" is not allowed. Possible tag names are:
<createDataTypesRequest>,<createDataTypesResponse>,<echoRequest>,
<echoResponse>,<secureEchoRequest>,<secureEchoResponse>
the document is NOT valid.
I'm somehow confused now...any idea what's wrong?
Upgrading to a newer XML parser (such as Xerces 2.8.0) might help.
I haven't added a parser, so i think i'm using the build in parser of java5. How can i switch to the xerces-j 2.8 parser?
Cheers,
Ingo