Author: veithen
Date: Tue Dec 19 19:14:01 2017
New Revision: 1818705
URL: http://svn.apache.org/viewvc?rev=1818705&view=rev
Log:
Add a schema validation module.
Added:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/
(with props)
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/pom.xml
(with props)
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
(with props)
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/resources/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/resources/META-INF/
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/resources/META-INF/module.xml
(with props)
Modified:
axis/axis2/java/core/branches/schema-validation/pom.xml
Propchange:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Dec 19 19:14:01 2017
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target
Added:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/schema-validation/modules/schema-validation/pom.xml?rev=1818705&view=auto
==============================================================================
---
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/pom.xml
(added)
+++
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/pom.xml
Tue Dec 19 19:14:01 2017
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>schema-validation</artifactId>
+ <packaging>mar</packaging>
+ <name>Apache Axis2 - Schema Validation Module</name>
+ <description>Module that validates incoming and outgoing messages against
the service's XML schema</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <url>http://axis.apache.org/axis2/java/core/</url>
+ <scm>
+
<connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/modules/schema-validation</connection>
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/modules/schema-validation</developerConnection>
+
<url>http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/schema-validation</url>
+ </scm>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <resourceBundles>
+
<resourceBundle>org.apache.axis2:axis2-resource-bundle:${project.version}</resourceBundle>
+ </resourceBundles>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-mar-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <includeDependencies>false</includeDependencies>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java?rev=1818705&view=auto
==============================================================================
---
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
(added)
+++
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
Tue Dec 19 19:14:01 2017
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.validation;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.xml.sax.SAXException;
+
+public class SchemaValidationHandler extends AbstractHandler {
+ public InvocationResponse invoke(MessageContext msgContext) throws
AxisFault {
+ SchemaFactory schemaFactory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ List<Source> schemas = new ArrayList<Source>();
+ for (XmlSchema schema : msgContext.getAxisService().getSchema()) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ schema.write(baos);
+ } catch (UnsupportedEncodingException ex) {
+ throw AxisFault.makeFault(ex);
+ }
+ schemas.add(new StreamSource(new
ByteArrayInputStream(baos.toByteArray())));
+ }
+ Schema schema;
+ try {
+ schema = schemaFactory.newSchema(schemas.toArray(new
Source[schemas.size()]));
+ } catch (SAXException ex) {
+ throw new AxisFault("Failed to compile schemas", ex);
+ }
+ try {
+
schema.newValidator().validate(msgContext.getEnvelope().getBody().getFirstElement().getSAXSource(true));
+ } catch (SAXException ex) {
+ throw new AxisFault("Failed to validate message", ex);
+ } catch (IOException ex) {
+ throw new AxisFault("Failed to validate message", ex);
+ } catch (OMException ex) {
+ throw AxisFault.makeFault(ex);
+ }
+ return InvocationResponse.CONTINUE;
+ }
+}
Propchange:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/resources/META-INF/module.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/resources/META-INF/module.xml?rev=1818705&view=auto
==============================================================================
---
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/resources/META-INF/module.xml
(added)
+++
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/resources/META-INF/module.xml
Tue Dec 19 19:14:01 2017
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<module name="schema-validation">
+ <Description>Schema Validation Module</Description>
+ <InFlow>
+ <handler name="SchemaValidationHandler"
class="org.apache.axis2.validation.SchemaValidationHandler">
+ <order phase="OperationInPhase"/>
+ </handler>
+ </InFlow>
+ <OutFlow>
+ <handler name="SchemaValidationHandler"
class="org.apache.axis2.validation.SchemaValidationHandler">
+ <order phase="OperationOutPhase"/>
+ </handler>
+ </OutFlow>
+</module>
Propchange:
axis/axis2/java/core/branches/schema-validation/modules/schema-validation/src/main/resources/META-INF/module.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis2/java/core/branches/schema-validation/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/schema-validation/pom.xml?rev=1818705&r1=1818704&r2=1818705&view=diff
==============================================================================
--- axis/axis2/java/core/branches/schema-validation/pom.xml (original)
+++ axis/axis2/java/core/branches/schema-validation/pom.xml Tue Dec 19 19:14:01
2017
@@ -59,6 +59,7 @@
<module>modules/samples/version</module>
<module>modules/soapmonitor/servlet</module>
<module>modules/soapmonitor/module</module>
+ <module>modules/schema-validation</module>
<module>modules/spring</module>
<module>modules/testutils</module>
<module>modules/tool/maven-shared</module>