C
chonkme
hi,
i have a web-service that accepts an xml string and needs to validate
it against the schema that is referenced in the incoming string. on the
client side, i use the same classes and methods and it works fine but
on the server side, with the file saved as a ".jws" file and sitting in
my "axis" directory, the same function (validateSchema) keeps throwing
a "throwable". the message provided with the throwable is simply
"Validator" which is the name of my class that extends the default
handler to schema validation. the relevant parts of the code are as
follows ...
public String thesisEndPoint(String requestMsg) {
....
schema = validateSchema(requestMsg);
.....
}
......
public static String validateSchema(String XmlDocument) {
SAXParser parser = new SAXParser();
String returnVal="";
try{
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
parser.setFeature("http://xml.org/sax/features/namespaces",true);
parser.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
Validator handler=new Validator();
StringReader resultString = new StringReader(XmlDocument);
parser.setErrorHandler(handler);
parser.parse(new InputSource(resultString));
if(handler.validationError==true) {
returnVal = "0";
}
else{
returnVal = "1";
}
}
catch(java.io.IOException ioe){
return ioe.getMessage();
}
catch (SAXException e) {
return e.getMessage();
}
catch (Exception f) {
return "in f + " + f.getMessage();
}
catch(Throwable t) {
return "in throwable: " + t.getMessage();
}
return returnVal;
}
/* end of class containing the service end point functions */
........
/* class to help with validating schema */
class Validator extends DefaultHandler {
public boolean validationError = false;
public SAXParseException saxParseException=null;
public void error(SAXParseException exception) throws SAXException {
validationError=true;
saxParseException=exception;
}
public void fatalError(SAXParseException exception) throws SAXException
{
validationError = true;
saxParseException=exception;
}
public void warning(SAXParseException exception) throws SAXException {}
}
the same problem happens if i make the "Validator" class private and
static and within the class that contains the service end point
functions. again, this validating method works fine on the client side
but just not on the service side. also, xerces is correctly installed
etc and on the classpath. any helps greatly appreciated, thanks
i have a web-service that accepts an xml string and needs to validate
it against the schema that is referenced in the incoming string. on the
client side, i use the same classes and methods and it works fine but
on the server side, with the file saved as a ".jws" file and sitting in
my "axis" directory, the same function (validateSchema) keeps throwing
a "throwable". the message provided with the throwable is simply
"Validator" which is the name of my class that extends the default
handler to schema validation. the relevant parts of the code are as
follows ...
public String thesisEndPoint(String requestMsg) {
....
schema = validateSchema(requestMsg);
.....
}
......
public static String validateSchema(String XmlDocument) {
SAXParser parser = new SAXParser();
String returnVal="";
try{
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
parser.setFeature("http://xml.org/sax/features/namespaces",true);
parser.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
Validator handler=new Validator();
StringReader resultString = new StringReader(XmlDocument);
parser.setErrorHandler(handler);
parser.parse(new InputSource(resultString));
if(handler.validationError==true) {
returnVal = "0";
}
else{
returnVal = "1";
}
}
catch(java.io.IOException ioe){
return ioe.getMessage();
}
catch (SAXException e) {
return e.getMessage();
}
catch (Exception f) {
return "in f + " + f.getMessage();
}
catch(Throwable t) {
return "in throwable: " + t.getMessage();
}
return returnVal;
}
/* end of class containing the service end point functions */
........
/* class to help with validating schema */
class Validator extends DefaultHandler {
public boolean validationError = false;
public SAXParseException saxParseException=null;
public void error(SAXParseException exception) throws SAXException {
validationError=true;
saxParseException=exception;
}
public void fatalError(SAXParseException exception) throws SAXException
{
validationError = true;
saxParseException=exception;
}
public void warning(SAXParseException exception) throws SAXException {}
}
the same problem happens if i make the "Validator" class private and
static and within the class that contains the service end point
functions. again, this validating method works fine on the client side
but just not on the service side. also, xerces is correctly installed
etc and on the classpath. any helps greatly appreciated, thanks