using catalog.cat
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 31 May 2015 23:38:50 +0000 (01:38 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 31 May 2015 23:38:50 +0000 (01:38 +0200)
README.md
web-services-spring-server/pom.xml
web-services-spring-server/src/main/build-resources/bindings/custombinding.xjb [new file with mode: 0644]
web-services-spring-server/src/main/build-resources/catalogs/catalog.cat [new file with mode: 0644]
web-services-spring-server/src/main/resources/bindings/custombinding.xjb [deleted file]
web-services-spring-server/src/main/resources/examples.xsd [new file with mode: 0644]
web-services-spring-server/src/main/resources/spring-configuration/ws/soap-ws.xml
web-services-spring-server/src/main/resources/xsd/examples.xsd [deleted file]

index a9896b3..235ed8a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -13,8 +13,6 @@ mvn clean install -Dmaven.test.skip=true
 TODO: custom bindings when creating Java code from wsdl.
 TODO: using Jetty instead of Tomcat
 TODO: logging Spring information
-TODO: test catalog.cat support for Apache CXF (searching in classpath) See: http://labs.bsb.com/2011/01/usage-of-an-xml-catalog-in-the-xmlbeans-cxf-integration/
-and http://cxf.apache.org/cxf-xjc-plugin.html
 TODO: integration tests (client and server)
 
 For debugging: export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
index 9d1b91a..4909a82 100644 (file)
 
   <properties>
     <jetty.version>9.3.0.RC0</jetty.version>
-    <project.xsd.schemas.source.path>src/main/resources/xsd</project.xsd.schemas.source.path>
+    <project.xsd.schemas.source.path>src/main/resources</project.xsd.schemas.source.path>
     <project.xsd.schemas.target.path>${basedir}/target/generated-sources/src/main/java</project.xsd.schemas.target.path>
     <project.xsd.schemas.package.name>de.spring.webservices.auto</project.xsd.schemas.package.name>
-    <project.bindings.path>src/main/resources/bindings</project.bindings.path>
+    <project.bindings.path>src/main/build-resources/bindings</project.bindings.path>
+    <!-- Requires absolute path (because of that I am using ${basedir} -->
+    <project.catalogs.path>${basedir}/src/main/build-resources/catalogs</project.catalogs.path>
   </properties>
 
   <dependencies>
         <artifactId>jdom</artifactId>
     </dependency>
 
+
+    <!-- Global types -->
+    <dependency>
+        <groupId>de.spring.webservices</groupId>
+        <artifactId>web-services-spring-globalxsds</artifactId>
+        <version>${project.version}</version>
+    </dependency>
+
+
     <!-- Required by spring-ws-core -->
     <dependency>
         <groupId>wsdl4j</groupId>
             <artifactId>cxf-xjc-plugin</artifactId>
             <version>3.0.3</version>
             <configuration>
+                <fork>true</fork>
                 <extensions>
                     <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:3.0.3</extension>
                 </extensions>
                                 <extension>true</extension>
                                 <xsd>${project.xsd.schemas.source.path}/examples.xsd</xsd>
                                 <bindingFile>${project.bindings.path}/custombinding.xjb</bindingFile>
+                                <catalog>${project.catalogs.path}/catalog.cat</catalog>
                                 <packagename>${project.xsd.schemas.package.name}</packagename>
                                 <extensionArgs>
                                     <extraarg>-Xinheritance</extraarg>
diff --git a/web-services-spring-server/src/main/build-resources/bindings/custombinding.xjb b/web-services-spring-server/src/main/build-resources/bindings/custombinding.xjb
new file mode 100644 (file)
index 0000000..a1430d5
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<jaxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
+    xmlns:annox="http://annox.dev.java.net"
+    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
+    jaxb:version="2.1"
+    jaxb:extensionBindingPrefixes="xjc inheritance annox">
+    
+    <!--
+    Se procesa con Xpath si quieres meter expresiones regulares y cosas así en teoría dependes de Xpath
+    por ejemplo esto: @name=match[.] se supone que debería funcionar pero me dice que no puede
+    cambiar mas de un nodo a la vez. Puede que sea un bug de xjc que se carga las opciones de Xpath :/
+    <jaxb:bindings schemaLocation="examples.xsd"> 
+        <jaxb:bindings node="//xsd:element[@name='ExampleRequest']/xsd:complexType">
+                <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+        </jaxb:bindings>
+        <jaxb:bindings node="//xsd:element[@name='ExampleResponse']/xsd:complexType">
+                <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+        </jaxb:bindings>
+    </jaxb:bindings>
+    -->
+
+    <jaxb:bindings schemaLocation="../../resources/examples.xsd"> 
+        <jaxb:bindings node="//xsd:element[@name='CustomBindingExampleRequest']/xsd:complexType">
+                <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+                <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
+        </jaxb:bindings>
+    </jaxb:bindings>
+
+
+    <jaxb:bindings schemaLocation="../../resources/examples.xsd"> 
+        <jaxb:bindings node="//xsd:element[@name='CustomBindingExampleResponse']/xsd:complexType">
+                <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+                <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
+        </jaxb:bindings>
+    </jaxb:bindings>
+
+    <!-- The same applies to annotate. If you do not want or you may not modify your xsd files you can
+         modify instead this file with your custom binding :) -->
+
+    <!-- Custom xs:dateTime adapter
+         See: https://jaxb.java.net/2.2.4/docs/vendorCustomizations.html#javaType
+    -->
+    <jaxb:globalBindings>
+       <xjc:javaType adapter="de.spring.webservices.binders.XSDateTimeCustomBinder"
+            name="java.util.Date" xmlType="xs:dateTime" />
+    </jaxb:globalBindings>
+
+</jaxb:bindings>
diff --git a/web-services-spring-server/src/main/build-resources/catalogs/catalog.cat b/web-services-spring-server/src/main/build-resources/catalogs/catalog.cat
new file mode 100644 (file)
index 0000000..2709d38
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public|system|uri" xml:base="http://gumartinm.name" >
+
+    <!--
+        See: http://labs.bsb.com/2011/01/usage-of-an-xml-catalog-in-the-xmlbeans-cxf-integration/
+             http://cxf.apache.org/cxf-xjc-plugin.html 
+             https://jaxb.java.net/2.2.4/docs/catalog.html
+    -->
+
+    <uri name="http://gumartinm.name/spring-ws/parent/parent.xsd" uri="classpath:parent.xsd"/>
+
+    <rewriteURI uriStartString="http://gumartinm.name/spring-ws/parent/parent.xsd"
+                rewritePrefix="classpath:parent.xsd"/>
+
+    <rewriteSystem systemIdStartString="http://gumartinm.name/spring-ws/parent/parent.xsd" rewritePrefix="classpath:parent.xsd"/>
+</catalog>
diff --git a/web-services-spring-server/src/main/resources/bindings/custombinding.xjb b/web-services-spring-server/src/main/resources/bindings/custombinding.xjb
deleted file mode 100644 (file)
index 726784a..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<jaxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
-    xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
-    xmlns:annox="http://annox.dev.java.net"
-    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
-    jaxb:version="2.1"
-    jaxb:extensionBindingPrefixes="xjc inheritance annox">
-    
-    <!--
-    Se procesa con Xpath si quieres meter expresiones regulares y cosas así en teoría dependes de Xpath
-    por ejemplo esto: @name=match[.] se supone que debería funcionar pero me dice que no puede
-    cambiar mas de un nodo a la vez. Puede que sea un bug de xjc que se carga las opciones de Xpath :/
-    <jaxb:bindings schemaLocation="examples.xsd"> 
-        <jaxb:bindings node="//xsd:element[@name='ExampleRequest']/xsd:complexType">
-                <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
-        </jaxb:bindings>
-        <jaxb:bindings node="//xsd:element[@name='ExampleResponse']/xsd:complexType">
-                <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
-        </jaxb:bindings>
-    </jaxb:bindings>
-    -->
-
-    <jaxb:bindings schemaLocation="../xsd/examples.xsd"> 
-        <jaxb:bindings node="//xsd:element[@name='CustomBindingExampleRequest']/xsd:complexType">
-                <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
-                <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
-        </jaxb:bindings>
-    </jaxb:bindings>
-
-
-    <jaxb:bindings schemaLocation="../xsd/examples.xsd"> 
-        <jaxb:bindings node="//xsd:element[@name='CustomBindingExampleResponse']/xsd:complexType">
-                <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
-                <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
-        </jaxb:bindings>
-    </jaxb:bindings>
-
-    <!-- The same applies to annotate. If you do not want or you may not modify your xsd files you can
-         modify instead this file with your custom binding :) -->
-
-    <!-- Custom xs:dateTime adapter -->
-    <jaxb:globalBindings>
-       <xjc:javaType adapter="de.spring.webservices.binders.XSDateTimeCustomBinder"
-            name="java.util.Date" xmlType="xs:dateTime" />
-    </jaxb:globalBindings>
-
-</jaxb:bindings>
diff --git a/web-services-spring-server/src/main/resources/examples.xsd b/web-services-spring-server/src/main/resources/examples.xsd
new file mode 100644 (file)
index 0000000..fa85466
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:parent="http://gumartinm.name/spring-ws/parent"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
+    xmlns:annox="http://annox.dev.java.net"
+    jaxb:version="2.1"
+    jaxb:extensionBindingPrefixes="inheritance annox"
+    elementFormDefault="qualified"
+    targetNamespace="http://gumartinm.name/spring-ws/example">
+
+    <!--
+        We are going to use catalog.cat in order to avoid downloading parent.xsd from remote server
+    -->
+    <xs:import namespace="http://gumartinm.name/spring-ws/parent" schemaLocation="http://gumartinm.name/spring-ws/parent/parent.xsd" />
+
+
+       <!-- Using inheritance and annox plugin -->
+       <xs:element name="ExampleRequest">
+          <xs:complexType>
+              <xs:annotation>
+                <xs:appinfo>
+                    <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate> 
+                    <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+                </xs:appinfo>
+            </xs:annotation>   
+            <xs:all>
+                <xs:element name="data" type="xs:string" />
+            </xs:all>
+        </xs:complexType>
+       </xs:element>
+    <xs:element name="ExampleResponse">
+        <xs:complexType>
+        <xs:annotation>
+                <xs:appinfo>
+                    <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+                </xs:appinfo>
+            </xs:annotation>  
+            <xs:all>
+                <xs:element name="data" type="xs:string" />
+            </xs:all>
+        </xs:complexType>
+    </xs:element>
+
+
+       <!-- Using custombinding.xjb instead of inheritance plugin.
+                Useful when you can not modify your xsd files because they are provided
+                by another person or company
+       -->
+    <xs:element name="CustomBindingExampleRequest">
+          <xs:complexType>
+            <xs:all>
+                <xs:element name="data" type="xs:string" />
+                <xs:element name="exampleDate" type="xs:dateTime" />
+                <xs:element name="parentEnum" type="parent:parentEnumType" />
+            </xs:all>
+        </xs:complexType>
+       </xs:element>
+    <xs:element name="CustomBindingExampleResponse">
+        <xs:complexType>
+            <xs:all>
+                <xs:element name="data" type="xs:string" />
+                <xs:element name="exampleDate" type="xs:dateTime" />
+                <xs:element name="parentEnum" type="parent:parentEnumType" />
+            </xs:all>
+        </xs:complexType>
+    </xs:element>
+
+
+</xs:schema>
index 0f7854c..cdf79a5 100644 (file)
@@ -41,7 +41,7 @@
         createSoap12Binding="true" createSoap11Binding="false"
         locationUri="/spring-ws/example"
         targetNamespace="http://gumartinm.name/spring-ws/example">
-        <sws:xsd location="classpath:xsd/examples.xsd"/>
+        <sws:xsd location="classpath:examples.xsd"/>
     </sws:dynamic-wsdl>
 
 
@@ -71,7 +71,7 @@
         -->
         <bean id="validatingInterceptor" 
             class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
-            <property name="schema" value="classpath:xsd/examples.xsd"/>
+            <property name="schema" value="classpath:examples.xsd"/>
             <property name="validateRequest" value="true"/>
             <property name="validateResponse" value="true"/>
         </bean>
diff --git a/web-services-spring-server/src/main/resources/xsd/examples.xsd b/web-services-spring-server/src/main/resources/xsd/examples.xsd
deleted file mode 100644 (file)
index ec642a9..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
-    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
-    xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
-    xmlns:annox="http://annox.dev.java.net"
-    jaxb:version="2.1"
-    jaxb:extensionBindingPrefixes="inheritance annox"
-    elementFormDefault="qualified"
-    targetNamespace="http://gumartinm.name/spring-ws/example">
-       
-
-       <!-- Using inheritance and annox plugin -->
-       <xs:element name="ExampleRequest">
-          <xs:complexType>
-              <xs:annotation>
-                <xs:appinfo>
-                    <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate> 
-                    <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
-                </xs:appinfo>
-            </xs:annotation>   
-            <xs:all>
-                <xs:element name="data" type="xs:string" />
-            </xs:all>
-        </xs:complexType>
-       </xs:element>
-    <xs:element name="ExampleResponse">
-        <xs:complexType>
-        <xs:annotation>
-                <xs:appinfo>
-                    <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
-                </xs:appinfo>
-            </xs:annotation>  
-            <xs:all>
-                <xs:element name="data" type="xs:string" />
-            </xs:all>
-        </xs:complexType>
-    </xs:element>
-
-
-       <!-- Using custombinding.xjb instead of inheritance plugin.
-                Useful when you can not modify your xsd files because they are provided
-                by another person or company
-       -->
-    <xs:element name="CustomBindingExampleRequest">
-          <xs:complexType>
-            <xs:all>
-                <xs:element name="data" type="xs:string" />
-                <xs:element name="exampleDate" type="xs:dateTime" />
-            </xs:all>
-        </xs:complexType>
-       </xs:element>
-    <xs:element name="CustomBindingExampleResponse">
-        <xs:complexType>
-            <xs:all>
-                <xs:element name="data" type="xs:string" />
-                <xs:element name="exampleDate" type="xs:dateTime" />
-            </xs:all>
-        </xs:complexType>
-    </xs:element>
-
-
-</xs:schema>