Spring WS How to get all error messages when validation fails
Asked Answered
I

1

0

When xsd validation fails I am trying to get all the error messages (SOAP detail element) and save them. Code below works but only brings the first error, how can I get all of them ?

public class PayloadValidationgInterceptorCustom extends
    PayloadValidatingInterceptor {

 @Override
protected Source getValidationRequestSource(WebServiceMessage  webSerMessage)   {
     source = webSerMessage.getPayloadSource();
     validateSchema(source);
     return source;  
}

private void validateSchema(Source source) throws Exception {        
  SchemaFactory schemaFactory =   
        SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  Schema schema = schemaFactory.newSchema(getSchemas()[0].getFile());

  Validator validator = schema.newValidator();
  DOMResult result = new DOMResult();
 try {
     validator.validate(source, result);          
 } catch (SAXException _exception) {

      //?????? 
      //save error mesg to database
      //but this exception only has one error message            
}

}

Illustrator answered 5/6, 2015 at 16:7 Comment(0)
J
0

The response is the same as here; you can look at

protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors)

you have an array of ParseException and you can dump all of them.

Joon answered 12/6, 2015 at 7:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.