public abstract class AbstractValidatingInterceptor extends TransformerObjectSupport implements EndpointInterceptor, org.springframework.beans.factory.InitializingBean
EndpointInterceptor implementations that validate part of the message using a
schema. The exact message part is determined by the getValidationRequestSource and
getValidationResponseSource template methods.
By default, only the request message is validated, but this behaviour can be changed using the
validateRequest and validateResponse properties.
getValidationRequestSource(org.springframework.ws.WebServiceMessage),
getValidationResponseSource(org.springframework.ws.WebServiceMessage)logger| Constructor and Description |
|---|
AbstractValidatingInterceptor() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterCompletion(MessageContext messageContext,
Object endpoint,
Exception ex)
Does nothing by default.
|
void |
afterPropertiesSet() |
String |
getSchemaLanguage() |
org.springframework.core.io.Resource[] |
getSchemas()
Returns the schema resources to use for validation.
|
protected abstract Source |
getValidationRequestSource(WebServiceMessage request)
Abstract template method that returns the part of the request message that is to be validated.
|
protected abstract Source |
getValidationResponseSource(WebServiceMessage response)
Abstract template method that returns the part of the response message that is to be validated.
|
boolean |
handleFault(MessageContext messageContext,
Object endpoint)
Does nothing by default.
|
boolean |
handleRequest(MessageContext messageContext,
Object endpoint)
Validates the request message in the given message context.
|
protected boolean |
handleRequestValidationErrors(MessageContext messageContext,
SAXParseException[] errors)
Template method that is called when the request message contains validation errors.
|
boolean |
handleResponse(MessageContext messageContext,
Object endpoint)
Validates the response message in the given message context.
|
protected boolean |
handleResponseValidationErrors(MessageContext messageContext,
SAXParseException[] errors)
Template method that is called when the response message contains validation errors.
|
void |
setErrorHandler(ValidationErrorHandler errorHandler)
Sets the error handler to use for validation.
|
void |
setSchema(org.springframework.core.io.Resource schema)
Sets the schema resource to use for validation.
|
void |
setSchemaLanguage(String schemaLanguage)
Sets the schema language.
|
void |
setSchemas(org.springframework.core.io.Resource[] schemas)
Sets the schema resources to use for validation.
|
void |
setValidateRequest(boolean validateRequest)
Indicates whether the request should be validated against the schema.
|
void |
setValidateResponse(boolean validateResponse)
Indicates whether the response should be validated against the schema.
|
void |
setXsdSchema(XsdSchema schema)
Sets the
XsdSchema to use for validation. |
void |
setXsdSchemaCollection(XsdSchemaCollection schemaCollection)
Sets the
XsdSchemaCollection to use for validation. |
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transformpublic String getSchemaLanguage()
public void setSchemaLanguage(String schemaLanguage)
http://www.w3.org/2001/XMLSchema".public org.springframework.core.io.Resource[] getSchemas()
public void setSchema(org.springframework.core.io.Resource schema)
xsdSchemaCollection, schema, or schemas is required.public void setSchemas(org.springframework.core.io.Resource[] schemas)
xsdSchemaCollection, schema, or schemas is required.public void setXsdSchema(XsdSchema schema)
XsdSchema to use for validation. Setting this property, xsdSchemaCollection, schema, or schemas is required.schema - the xsd schema to useIOException - in case of I/O errorspublic void setXsdSchemaCollection(XsdSchemaCollection schemaCollection)
XsdSchemaCollection to use for validation. Setting this property, xsdSchema, schema, or schemas is required.schemaCollection - the xsd schema collection to useIOException - in case of I/O errorspublic void setErrorHandler(ValidationErrorHandler errorHandler)
errorHandler - the error handler.public void setValidateRequest(boolean validateRequest)
true.public void setValidateResponse(boolean validateResponse)
false.public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic boolean handleRequest(MessageContext messageContext, Object endpoint) throws IOException, SAXException, TransformerException
validateRequest is set to true, which is the default.
Returns true if the request is valid, or false if it isn't. Additionally, when the
request message is a SoapMessage, a SoapFault is added as response.
handleRequest in interface EndpointInterceptormessageContext - the message contextendpoint - chosen endpoint to invoketrue if the message is valid; false otherwiseIOExceptionSAXExceptionTransformerExceptionsetValidateRequest(boolean)protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors) throws TransformerException
false, i.e. do not process the request.messageContext - the message contexterrors - the validation errorstrue to continue processing the request, false (the default) otherwiseTransformerExceptionpublic boolean handleResponse(MessageContext messageContext, Object endpoint) throws IOException, SAXException
validateResponse is set to true, which is not the default.
Returns true if the request is valid, or false if it isn't.
handleResponse in interface EndpointInterceptormessageContext - the message context.endpoint - chosen endpoint to invoketrue if the response is valid; false otherwiseIOExceptionSAXExceptionsetValidateResponse(boolean)protected boolean handleResponseValidationErrors(MessageContext messageContext, SAXParseException[] errors)
false, i.e. do not cot continue to process the response interceptor chain.messageContext - the message contexterrors - the validation errorstrue to continue the response interceptor chain, false (the default) otherwisepublic boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception
handleFault in interface EndpointInterceptormessageContext - contains both request and response messages, the response should contains a Faultendpoint - chosen endpoint to invoketrue to continue processing of the response interceptor chain; false to indicate
blocking of the response handler chain.Exceptionpublic void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex)
afterCompletion in interface EndpointInterceptormessageContext - contains both request and response messages, the response should contains a Faultendpoint - chosen endpoint to invokeex - exception thrown on handler execution, if anyprotected abstract Source getValidationRequestSource(WebServiceMessage request)
request - the request messagenull not to validate anythingprotected abstract Source getValidationResponseSource(WebServiceMessage response)
response - the response messagenull not to validate anything