How do I Instantiate a schema Object from a WSDL file using JAXP ?
I'm new to JAXP and I want to validate a SOAP message payload. To do that I need to instantiate
a Schema Object and invoke the validate method in it. The problem is
that schema is embedded inside a WSDL (element ) and
I'm trying to read it into a DOMsource and then I use it to create
new Schema object like this:
1 Schema schema = schemaFactory.newSchema(getDomSource(is));
2 Validator validator = schema.newValidator();
3 validator.validate(msgContent);
The problem is, this should work fine if "is" was a InputStream
opened in a regular XSD file. But in this case, I'm using a WSDL
file, what I'm doing is fetching the Element inside
the WSDL file and using it to instantiate a DOMSource, which then I
use, as stated above, to instantiate a Schema Object from that
DOMSource. The problem is that I'm getting an error in the Schema
object instantiation (line 1 above). The error says the following:
org.xml.sax.SAXParseException: s4s-elt-schema-ns: The namespace of element 'xs:s
chema' must be from the schema namespace, ''.
I've tried all other different ways of accomplish like creating a new empty Document (class org.w3c.dom.Document), and adding the Schema Node object to it, cloning the Schema Node, and all alternatives failed.
Can someone give an hint on how to solve this ?