1 /*
2 * Copyright 2005-2010 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.springframework.ws.soap.server.endpoint.interceptor;
18
19 import javax.xml.transform.Source;
20
21 import org.springframework.ws.WebServiceMessage;
22
23 /**
24 * Interceptor that validates the contents of <code>WebServiceMessage</code>s using a schema. Allows for both W3C XML
25 * and RELAX NG schemas.
26 * <p/>
27 * When the payload is invalid, this interceptor stops processing of the interceptor chain. Additionally, if the message
28 * is a SOAP request message, a SOAP Fault is created as reply. Invalid SOAP responses do not result in a fault.
29 * <p/>
30 * The schema to validate against is set with the <code>schema</code> property or <code>schemas</code> property. By
31 * default, only the request message is validated, but this behaviour can be changed using the
32 * <code>validateRequest</code> and <code>validateResponse</code> properties. Responses that contains faults are not
33 * validated.
34 *
35 * @author Arjen Poutsma
36 * @see #setSchema(org.springframework.core.io.Resource)
37 * @see #setSchemas(org.springframework.core.io.Resource[])
38 * @see #setValidateRequest(boolean)
39 * @see #setValidateResponse(boolean)
40 * @since 1.0.0
41 */
42 public class PayloadValidatingInterceptor extends AbstractFaultCreatingValidatingInterceptor {
43
44 /** Returns the payload source of the given message. */
45 @Override
46 protected Source getValidationRequestSource(WebServiceMessage request) {
47 return request.getPayloadSource();
48 }
49
50 /** Returns the payload source of the given message. */
51 @Override
52 protected Source getValidationResponseSource(WebServiceMessage response) {
53 return response.getPayloadSource();
54 }
55 }