【发布时间】:2015-06-05 16:07:25
【问题描述】:
当 xsd 验证失败时,我会尝试获取所有错误消息(SOAP 详细信息元素)并保存它们。下面的代码有效,但只带来第一个错误,我怎样才能得到所有这些错误?
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
}
}
【问题讨论】:
标签: java spring saxparser spring-ws