// Path: src/main/java/br/fatea/simplebank/soap/exceptions/InvalidClientArgumentsException.java
// @SoapFault(faultCode=FaultCode.CLIENT, faultStringOrReason="Invalid Request Parameters")
// public class InvalidClientArgumentsException extends RuntimeException {
// 
// 	private static final long serialVersionUID = -2188675525576989114L;
// 
// 	public InvalidClientArgumentsException(String details) {
// 		super(details);
// 	}
// 	
// }


import java.io.IOException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;
import org.xml.sax.SAXException;
import br.fatea.simplebank.soap.exceptions.InvalidClientArgumentsException;
package br.fatea.simplebank.soap.interceptors;





public class ValidationInterceptor extends PayloadValidatingInterceptor {

	protected Source getValidationRequestSource(WebServiceMessage request) {
		Source source = request.getPayloadSource();
		validateSchema(source);
		return source;
	}

	private void validateSchema(Source source) {
		SchemaFactory schemaFactory = SchemaFactory.newInstance(getSchemaLanguage());
		try {
			Schema schema = schemaFactory.newSchema(getSchemas()[0].getFile());
			Validator validator = schema.newValidator();
			DOMResult result = new DOMResult();
			try {
				validator.validate(source, result);
				
			} catch (SAXException ex) {
				logger.error(ex);
// Path: src/main/java/br/fatea/simplebank/soap/exceptions/InvalidClientArgumentsException.java
// @SoapFault(faultCode=FaultCode.CLIENT, faultStringOrReason="Invalid Request Parameters")
// public class InvalidClientArgumentsException extends RuntimeException {
// 
// 	private static final long serialVersionUID = -2188675525576989114L;
// 
// 	public InvalidClientArgumentsException(String details) {
// 		super(details);
// 	}
// 	
// }


// Path: src/main/java/br/fatea/simplebank/soap/interceptors/ValidationInterceptor.java
import java.io.IOException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;
import org.xml.sax.SAXException;
import br.fatea.simplebank.soap.exceptions.InvalidClientArgumentsException;

package br.fatea.simplebank.soap.interceptors;





public class ValidationInterceptor extends PayloadValidatingInterceptor {

	protected Source getValidationRequestSource(WebServiceMessage request) {
		Source source = request.getPayloadSource();
		validateSchema(source);
		return source;
	}

	private void validateSchema(Source source) {
		SchemaFactory schemaFactory = SchemaFactory.newInstance(getSchemaLanguage());
		try {
			Schema schema = schemaFactory.newSchema(getSchemas()[0].getFile());
			Validator validator = schema.newValidator();
			DOMResult result = new DOMResult();
			try {
				validator.validate(source, result);
				
			} catch (SAXException ex) {
				logger.error(ex);
				throw new InvalidClientArgumentsException(ex.getMessage());