diff --git a/src/docbkx/server.xml b/src/docbkx/server.xml index 0b853b89..7f95641e 100644 --- a/src/docbkx/server.xml +++ b/src/docbkx/server.xml @@ -718,6 +718,125 @@ public class MarshallingOrderEndpoint extends AbstractMarshallingPayloadEndpoint marshaller bean. +
+ Using Spring <interfacename>Validator</interfacename> with Marshalling Endpoints + + It is possible to use Validator + objects in conjunction with marshalling endpoints in order to validate the unmarshalled payloads. + Spring-WS provides 2 extensions of AbstractMarshallingPayloadEndpoint for that purpose: + AbstractValidatingMarshallingPayloadEndpoint and + AbstractFaultCreatingValidatingMarshallingPayloadEndpoint. The former is the most + general whereas the latter specializes in creating SOAP faults in response to validation errors. + + + Both classes support setting one or more Validator objects via the + validator and validators properties respectively. + Note that all of the injected validators + must support the request object (through the supports method) + or else an IllegalArgumentException will be thrown. + + + + The default request object name used in the validator is request. + The error codes are generated in consequence. For instance, assuming a POJO with a + "name" property of type java.lang.String, + calling errors.rejectValue("name","invalidValue") in the + validate method of a Validator + generates the following error codes: + invalidValue.request.name, invalidValue.name, + invalidValue.java.lang.String and invalidValue. + Similarly, calling errors.reject("invalidValue") + generates invalidValue.request and invalidValue as error codes. + + +
+ <classname>AbstractValidatingMarshallingPayloadEndpoint</classname> + + Subclasses of AbstractValidatingMarshallingPayloadEndpoint + implement the validation error handling logic by overriding the onValidationErrors + method. This method is called when a validation error occurs and its return value + indicates whether the endpoint should continue processing the request or not. + + + In the following example, a custom error POJO is marshalled and sent as a response: + + +
+
+ <classname>AbstractFaultCreatingValidatingMarshallingPayloadEndpoint</classname> + + Endpoints of this type generate a SOAP fault whenever a validation error occurs. + By default, a fault detail element is generated for each validation error. + The error codes are resolved using the application context message source. + + + The properties of AbstractFaultCreatingValidatingMarshallingPayloadEndpoint + have sensible defaults, which makes its subclasses quite simple to configure as in the following example: + + + + + + + + + + + + +]]> + + In case of validation error, here is how the response might look like: + + + + + + SOAP-ENV:Client + Validation error + + + invalid user id: Ernie + + + invalid order + + + + + +]]> + + It is possible though to customize various aspects of the generated SOAP faults, such as the fault string + and the soap detail. + Please refer to the Javadoc + for the full list of available options. + +
+
<interfacename>@Endpoint</interfacename>