public static Schema getSchema(ServiceInfo serviceInfo) { return getSchema(serviceInfo, null); } public static Schema getSchema(ServiceInfo serviceInfo, Bus b) {
public static Schema getSchema(ServiceInfo serviceInfo) { return getSchema(serviceInfo, null); } public static Schema getSchema(ServiceInfo serviceInfo, Bus b) {
/** * Based on the Schema Validation configuration, will initialise the DataWriter with or without the schema set. */ private void setDataWriterValidation(Service service, Message message, DataWriter<?> writer) { if (shouldValidate(message)) { Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message.getExchange().getBus()); writer.setSchema(schema); } }
/** * Based on the Schema Validation configuration, will initialise the DataWriter with or without the schema set. */ private void setDataWriterValidation(Service service, Message message, DataWriter<?> writer) { if (shouldValidate(message)) { Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message.getExchange().getBus()); writer.setSchema(schema); } }
protected void validateMessage(SoapMessage message) throws Fault { Service service = ServiceModelUtil.getService(message.getExchange()); if (service != null) { Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0)); if (schema != null) { javax.xml.validation.Validator validator = schema.newValidator(); try { Element sourceMessage = new SourceTransformer().toDOMElement(message.getContent(Source.class)); message.setContent(Source.class, new DOMSource(sourceMessage)); if (!useJBIWrapper && !useSOAPEnvelope) { validator.validate(new DOMSource(sourceMessage)); } else { Element partWrapper = DomUtil .getFirstChildElement(sourceMessage); while (partWrapper != null) { Element partContent = DomUtil .getFirstChildElement(partWrapper); validator.validate(new DOMSource(partContent)); partWrapper = DomUtil .getNextSiblingElement(partWrapper); } } } catch (Exception e) { throw new Fault(e); } } } }
/** * Based on the Schema Validation configuration, will initialise the * DataReader with or without the schema set. * * Can also be called to override schema validation at operation level, thus the reader.setSchema(null) * to remove schema validation */ protected void setDataReaderValidation(Service service, Message message, DataReader<?> reader) { if (shouldValidate(message)) { //all serviceInfos have the same schemas Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message.getExchange().getBus()); reader.setSchema(schema); } else { reader.setSchema(null); // if this is being called for an operation, then override the service level } }
/** * Based on the Schema Validation configuration, will initialise the * DataReader with or without the schema set. * * Can also be called to override schema validation at operation level, thus the reader.setSchema(null) * to remove schema validation */ protected void setDataReaderValidation(Service service, Message message, DataReader<?> reader) { if (shouldValidate(message)) { //all serviceInfos have the same schemas Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message.getExchange().getBus()); reader.setSchema(schema); } else { reader.setSchema(null); // if this is being called for an operation, then override the service level } }