本文整理了Java中org.springframework.xml.validation.XmlValidator
类的一些代码示例,展示了XmlValidator
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlValidator
类的具体详情如下:
包路径:org.springframework.xml.validation.XmlValidator
类名称:XmlValidator
[英]Simple processor that validates a given Source. Can be created via the XmlValidatorFactory.
Instances of this class are designed to be thread safe.
[中]验证给定源的简单处理器。可以通过XmlValidatorFactory创建。
此类的实例被设计为线程安全的。
代码示例来源:origin: spring-projects/spring-integration
@Override
public boolean accept(Message<?> message) {
SAXParseException[] validationExceptions = null;
try {
validationExceptions = this.xmlValidator.validate(this.converter.convertToSource(message.getPayload()));
}
catch (Exception e) {
throw new MessageHandlingException(message, e);
}
boolean validationSuccess = ObjectUtils.isEmpty(validationExceptions);
if (!validationSuccess) {
if (this.throwExceptionOnRejection) {
throw new MessageRejectedException(message, "Message was rejected due to XML Validation errors",
new AggregatedXmlMessageValidationException(Arrays.asList(validationExceptions)));
}
else if (this.logger.isInfoEnabled()) {
this.logger.info("Message was rejected due to XML Validation errors",
new AggregatedXmlMessageValidationException(Arrays.asList(validationExceptions)));
}
}
return validationSuccess;
}
代码示例来源:origin: net.javacrumbs/spring-ws-test
public void validate(WebServiceMessage message, XmlValidator validator) throws IOException{
Source requestSource = message.getPayloadSource();
if (requestSource != null) {
SAXParseException[] errors = validator.validate(requestSource);
if (!ObjectUtils.isEmpty(errors)) {
handleRequestValidationErrors(message, errors);
}
logger.debug("Request message validated");
}
else
{
logger.warn("Request source is null");
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public void match(WebServiceMessage message) throws IOException, AssertionError {
SAXParseException[] exceptions = xmlValidator.validate(message.getPayloadSource());
if (!ObjectUtils.isEmpty(exceptions)) {
fail("XML is not valid: " + Arrays.toString(exceptions), "Payload", message.getPayloadSource());
}
}
}
代码示例来源:origin: spring-projects/spring-ws
@Override
public void match(WebServiceMessage message) throws IOException, AssertionError {
SAXParseException[] exceptions = xmlValidator.validate(message.getPayloadSource());
if (!ObjectUtils.isEmpty(exceptions)) {
fail("XML is not valid: " + Arrays.toString(exceptions), "Payload", message.getPayloadSource());
}
}
}
代码示例来源:origin: org.springframework.ws/spring-ws-test
@Override
public void match(WebServiceMessage message) throws IOException, AssertionError {
SAXParseException[] exceptions = xmlValidator.validate(message.getPayloadSource());
if (!ObjectUtils.isEmpty(exceptions)) {
fail("XML is not valid: " + Arrays.toString(exceptions), "Payload", message.getPayloadSource());
}
}
}
代码示例来源:origin: org.springframework.ws/spring-ws-core
/**
* Validates the response message in the given message context. Validation only occurs if
* {@code validateResponse} is set to {@code true}, which is <strong>not</strong> the default.
*
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't.
*
* @param messageContext the message context.
* @return {@code true} if the response is valid; {@code false} otherwise
* @see #setValidateResponse(boolean)
*/
@Override
public boolean handleResponse(MessageContext messageContext, Object endpoint) throws IOException, SAXException {
if (validateResponse) {
Source responseSource = getValidationResponseSource(messageContext.getResponse());
if (responseSource != null) {
SAXParseException[] errors = validator.validate(responseSource, errorHandler);
if (!ObjectUtils.isEmpty(errors)) {
return handleResponseValidationErrors(messageContext, errors);
}
else if (logger.isDebugEnabled()) {
logger.debug("Response message validated");
}
}
}
return true;
}
代码示例来源:origin: spring-projects/spring-ws
/**
* Validates the response message in the given message context. Validation only occurs if
* {@code validateResponse} is set to {@code true}, which is <strong>not</strong> the default.
*
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't.
*
* @param messageContext the message context.
* @return {@code true} if the response is valid; {@code false} otherwise
* @see #setValidateResponse(boolean)
*/
@Override
public boolean handleResponse(MessageContext messageContext, Object endpoint) throws IOException, SAXException {
if (validateResponse) {
Source responseSource = getValidationResponseSource(messageContext.getResponse());
if (responseSource != null) {
SAXParseException[] errors = validator.validate(responseSource, errorHandler);
if (!ObjectUtils.isEmpty(errors)) {
return handleResponseValidationErrors(messageContext, errors);
}
else if (logger.isDebugEnabled()) {
logger.debug("Response message validated");
}
}
}
return true;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Validates the response message in the given message context. Validation only occurs if
* {@code validateResponse} is set to {@code true}, which is <strong>not</strong> the default.
*
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't.
*
* @param messageContext the message context.
* @return {@code true} if the response is valid; {@code false} otherwise
* @see #setValidateResponse(boolean)
*/
@Override
public boolean handleResponse(MessageContext messageContext, Object endpoint) throws IOException, SAXException {
if (validateResponse) {
Source responseSource = getValidationResponseSource(messageContext.getResponse());
if (responseSource != null) {
SAXParseException[] errors = validator.validate(responseSource, errorHandler);
if (!ObjectUtils.isEmpty(errors)) {
return handleResponseValidationErrors(messageContext, errors);
}
else if (logger.isDebugEnabled()) {
logger.debug("Response message validated");
}
}
}
return true;
}
代码示例来源:origin: org.springframework.ws/org.springframework.ws
/**
* Validates the response message in the given message context. Validation only occurs if
* <code>validateResponse</code> is set to <code>true</code>, which is <strong>not</strong> the default.
* <p/>
* Returns <code>true</code> if the request is valid, or <code>false</code> if it isn't.
*
* @param messageContext the message context.
* @return <code>true</code> if the response is valid; <code>false</code> otherwise
* @see #setValidateResponse(boolean)
*/
public boolean handleResponse(MessageContext messageContext, Object endpoint) throws IOException, SAXException {
if (validateResponse) {
Source responseSource = getValidationResponseSource(messageContext.getResponse());
if (responseSource != null) {
SAXParseException[] errors = validator.validate(responseSource);
if (!ObjectUtils.isEmpty(errors)) {
return handleResponseValidationErrors(messageContext, errors);
}
else if (logger.isDebugEnabled()) {
logger.debug("Response message validated");
}
}
}
return true;
}
代码示例来源:origin: spring-projects/spring-ws
/**
* Validates the request message in the given message context. Validation only occurs if
* {@code validateRequest} is set to {@code true}, which is the default.
*
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't. Additionally, when the
* request message is a {@link SoapMessage}, a {@link SoapFault} is added as response.
*
* @param messageContext the message context
* @return {@code true} if the message is valid; {@code false} otherwise
* @see #setValidateRequest(boolean)
*/
@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
throws IOException, SAXException, TransformerException {
if (validateRequest) {
Source requestSource = getValidationRequestSource(messageContext.getRequest());
if (requestSource != null) {
SAXParseException[] errors = validator.validate(requestSource, errorHandler);
if (!ObjectUtils.isEmpty(errors)) {
return handleRequestValidationErrors(messageContext, errors);
}
else if (logger.isDebugEnabled()) {
logger.debug("Request message validated");
}
}
}
return true;
}
代码示例来源:origin: org.springframework.ws/spring-ws-core
/**
* Validates the request message in the given message context. Validation only occurs if
* {@code validateRequest} is set to {@code true}, which is the default.
*
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't. Additionally, when the
* request message is a {@link SoapMessage}, a {@link SoapFault} is added as response.
*
* @param messageContext the message context
* @return {@code true} if the message is valid; {@code false} otherwise
* @see #setValidateRequest(boolean)
*/
@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
throws IOException, SAXException, TransformerException {
if (validateRequest) {
Source requestSource = getValidationRequestSource(messageContext.getRequest());
if (requestSource != null) {
SAXParseException[] errors = validator.validate(requestSource, errorHandler);
if (!ObjectUtils.isEmpty(errors)) {
return handleRequestValidationErrors(messageContext, errors);
}
else if (logger.isDebugEnabled()) {
logger.debug("Request message validated");
}
}
}
return true;
}
代码示例来源:origin: org.springframework.ws/org.springframework.ws
/**
* Validates the request message in the given message context. Validation only occurs if
* <code>validateRequest</code> is set to <code>true</code>, which is the default.
* <p/>
* Returns <code>true</code> if the request is valid, or <code>false</code> if it isn't. Additionally, when the
* request message is a {@link SoapMessage}, a {@link SoapFault} is added as response.
*
* @param messageContext the message context
* @return <code>true</code> if the message is valid; <code>false</code> otherwise
* @see #setValidateRequest(boolean)
*/
public boolean handleRequest(MessageContext messageContext, Object endpoint)
throws IOException, SAXException, TransformerException {
if (validateRequest) {
Source requestSource = getValidationRequestSource(messageContext.getRequest());
if (requestSource != null) {
SAXParseException[] errors = validator.validate(requestSource);
if (!ObjectUtils.isEmpty(errors)) {
return handleRequestValidationErrors(messageContext, errors);
}
else if (logger.isDebugEnabled()) {
logger.debug("Request message validated");
}
}
}
return true;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Validates the request message in the given message context. Validation only occurs if
* {@code validateRequest} is set to {@code true}, which is the default.
*
* <p>Returns {@code true} if the request is valid, or {@code false} if it isn't. Additionally, when the
* request message is a {@link SoapMessage}, a {@link SoapFault} is added as response.
*
* @param messageContext the message context
* @return {@code true} if the message is valid; {@code false} otherwise
* @see #setValidateRequest(boolean)
*/
@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
throws IOException, SAXException, TransformerException {
if (validateRequest) {
Source requestSource = getValidationRequestSource(messageContext.getRequest());
if (requestSource != null) {
SAXParseException[] errors = validator.validate(requestSource, errorHandler);
if (!ObjectUtils.isEmpty(errors)) {
return handleRequestValidationErrors(messageContext, errors);
}
else if (logger.isDebugEnabled()) {
logger.debug("Request message validated");
}
}
}
return true;
}
代码示例来源:origin: org.springframework.ws/spring-ws-core
SAXParseException[] errors;
try {
errors = validator.validate(requestSource);
代码示例来源:origin: org.springframework.ws/org.springframework.ws
SAXParseException[] errors;
try {
errors = validator.validate(requestSource);
代码示例来源:origin: apache/servicemix-bundles
SAXParseException[] errors;
try {
errors = validator.validate(responseSource);
代码示例来源:origin: org.springframework.ws/spring-ws-core
SAXParseException[] errors;
try {
errors = validator.validate(responseSource);
代码示例来源:origin: spring-projects/spring-ws
SAXParseException[] errors;
try {
errors = validator.validate(requestSource);
代码示例来源:origin: org.springframework.ws/org.springframework.ws
SAXParseException[] errors;
try {
errors = validator.validate(responseSource);
代码示例来源:origin: apache/servicemix-bundles
SAXParseException[] errors;
try {
errors = validator.validate(requestSource);
内容来源于网络,如有侵权,请联系作者删除!