当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
}
}
答案 0 :(得分:0)
回复与here相同;你可以看看
Double initialValue = 7.12;
int finalValue = initialValue.intValue();
你有一个ParseException数组,你可以转储所有这些。