Eran Chinthaka wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Please read a doc on data binding and please

1. do not cross post
2. do not use dev-list to ask non-architectural questions.

Chinthaka

Wenshuang Sun wrote:
Hi,

How to use WSDL to validate the soap message in axis2, is the API
about the function  provided?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHHZ85jON2uBzUhh8RAtRGAJ9cQZIkS6+HQVieeCgzRFoPU4tuzACgldY2
Q9NuWsytX9oEaM19DTE5u/w=
=y11O
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


I've actually used the lib from Xerces. You need xml-apis.jar from there. Then I placed my .xsd files in the root of the archive file (aar) and my validation method is like this:

public String validate(String schemaFile, OMElement xml) {

       String returnMessage = null;
       try {
SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema";);

Schema schemaXSD = schemaFactory.newSchema(this.getClass().getResource("/" + schemaFile));
           Validator validator    = schemaXSD.newValidator();
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); InputSource docSource = new InputSource(new StringReader(xml.toString()));
           Document document      = parser.parse(docSource);
           validator.validate(new DOMSource(document));
       } catch (Exception e) {
           e.printStackTrace();
           returnMessage = e.toString();
           // Clear the org.xml.sax.SAXParseException from the string
           returnMessage = returnMessage.replaceAll(
                   "org\\.xml\\.sax\\.SAXParseException: ", "");
       }
       return returnMessage;
   }

For small messages I have not noticed a delay in the validation. But I still need to check with attachments. Also notice the "/" in the getResource. This
is crucial for finding the schema file in the archive.

Reply via email to