jaxb2: trying to use catalago. It is not working yet because plugin keeps downloading...
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Tue, 15 Dec 2015 02:07:25 +0000 (03:07 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Tue, 15 Dec 2015 02:07:25 +0000 (03:07 +0100)
jaxb2/web-services-spring-jaxb2-server/pom.xml
jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb
jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat
jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml

index b12472a..41425c7 100644 (file)
 
        <properties>
                <jetty.version>9.3.0.RC0</jetty.version>
-               <!-- Requires absolute path (because of that I am using ${basedir} -->
-               <project.catalogs.path>${basedir}/src/main/build-resources/catalogs</project.catalogs.path>
-
-
                <project.xsd.schemas.source.path>src/main/resources/schemas</project.xsd.schemas.source.path>
                <project.xsd.schemas.target.path>${project.build.directory}/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/build-resources/bindings</project.bindings.path>
-
        </properties>
 
        <dependencies>
 
                                        <!-- If true (default), XJC will perform strict validation of the input 
                                                schema. If strict is set to false XJC will be run with -nv, this disables 
-                                               strict validation of schemas. -->
-                                       <strict>true</strict>
+                                               strict validation of schemas.
+
+                                               The plugin is configured to use catalogs and strict mode at the 
+                                               same time. Using catalogs to resolve schema URIs in strict mode is known 
+                                               to be problematic and may fail. Please refer to the following link for more 
+                                               information: https://github.com/highsource/maven-jaxb2-plugin/wiki/Catalogs-in-Strict-Mode 
+                                               Consider setting <strict>false</strict> in your plugin configuration. -->
+                                       <strict>false</strict>
 
                                        <verbose>true</verbose>
 
                                                        <version>1.0.2</version>
                                                </plugin>
                                        </plugins>
+
+
+                                       <!--
+                                               GRAN DIFERENCIA:
+                                        
+                                               CON ESTE PLUGIN A DIFERENCIA DE cxf-xjc-plugin NO SE VUELVEN A GENERAR LOS OBJETOS DE parent.xsd
+                                               QUE SE ENCONTRABAN EN web-services-spring-jaxb2-globalxsds
+                                               
+                                               CON cxf-xjc-plugin SÍ SE VUELVEN A GENERAR INCLUSO AUNQUE USEMOS EPISODIOS :( 
+                                       -->
+                                               
+                                       <!-- You can use the useDependenciesAsEpisodes instead of configuring 
+                                               individual episodes. In this case all the dependencies will be treated as 
+                                               episodes which is very convenient (less configuration). I am going to use 
+                                               the long way (individual episodes) -->
+                                       <useDependenciesAsEpisodes>false</useDependenciesAsEpisodes>
+                                       <catalog>src/main/build-resources/catalogs/catalog.cat</catalog>
+                                       <episodes>
+                                               <episode>
+                                                       <groupId>de.spring.webservices</groupId>
+                                                       <artifactId>web-services-spring-jaxb2-globalxsds</artifactId>
+                                               </episode>
+                                       </episodes>
                                </configuration>
                        </plugin>
                        <plugin>
index a1430d5..1363870 100644 (file)
@@ -22,7 +22,7 @@
     </jaxb:bindings>
     -->
 
-    <jaxb:bindings schemaLocation="../../resources/examples.xsd"> 
+    <jaxb:bindings schemaLocation="../../resources/schemas/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>
@@ -30,7 +30,7 @@
     </jaxb:bindings>
 
 
-    <jaxb:bindings schemaLocation="../../resources/examples.xsd"> 
+    <jaxb:bindings schemaLocation="../../resources/schemas/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>
index 4bc1c66..44885d9 100644 (file)
@@ -1,38 +1,12 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system|public" >
 
-   <!--
-        An XML catalog will allow us to specify real locations for our imported XML schemas.
-        The XJC tool supports several different XML Catalog formats:  TR9401, XCatalog, OASIS XML Catalog.
-        I am using OASIS XML Catalog Format
-        
-        OASIS XML Catalog Format: https://www.oasis-open.org/committees/entity/specs/cs-entity-xml-catalogs-1.0.html
-        TR9401: https://www.oasis-open.org/specs/a401.htm
 
+REWRITE_SYSTEM "http://gumartinm.name/spring-ws/parent" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd"
+       
+--
+       This configuration is better (it relies on namespace instead of schemaLocation) but it doesn't work
+       because of this bug: https://java.net/jira/browse/JAXB-942
+       
+       PUBLIC "xmlns:parent" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd"
+       
+--
 
-        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
-    -->
-
-
-    <!-- I JUST NEED THIS CONFIGURATION, ANYHOW I AM WRITING ALL OF THEM -->
-    <rewriteSystem systemIdStartString="http://gumartinm.name/spring-ws/parent"
-                   rewritePrefix="classpath:parent.xsd"/>
-
-
-    <!-- THE FOLLOWING ONES ARE NOT REQUIRED EVEN IF I AM WRITING THEM -->
-    <public
-        publicId="http://gumartinm.name/spring-ws/parent"
-        uri="classpath:parent.xsd"/>
-
-
-    <system
-        systemId="http://gumartinm.name/spring-ws/parent/parent.xsd"
-        uri="classpath:parent.xsd"/>
-
-
-    <rewriteURI uriStartString="http://gumartinm.name/spring-ws/parent"
-                rewritePrefix="classpath:parent.xsd"/>
-
-</catalog>
index afabf4e..5f2293f 100644 (file)
          Searches for @PayloadRoot
         <sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller"/>
      -->
-    <sws:annotation-driven/>
+     
+     <!-- 
+       VOY A INSTANCIAR EXPLÍCITAMENTE EL Marshaller Y VOY A USAR packagesToScan
+       PORQUE TENGO DOS ObjectFactory CON EL MISMO package. UNO ESTÁ EN globalxsds Y OTRO
+       ESTÁ EN ESTE PROYECTO server.
+       
+       SI NO RECUERDO MAL HABÍA PROBLEMAS CUANDO SE TENÍA DOS ObjectFactory IGUALES Y
+       SE USABA contest-path.
+       
+       DE TODOS MODOS, PROBABLEMENTE HABRÍA QUE USAR UN PACKAGE DISTINTO PARA LO QUE HAY
+       EN globalxsds Y ASÍ PODRÍA EVITAR ESTA CONFIGURACIÓN :(
+      -->
+    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
+       <property name="packagesToScan" value="de.spring.webservices.auto"/>
+       </bean>
+    <sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller" />
 
     <!--
         Spring makes the WSDL file for us from the XSD file.
         createSoap12Binding="true" createSoap11Binding="false"
         locationUri="/spring-ws/example"
         targetNamespace="http://gumartinm.name/resource/wsdl/schemas">
-        <sws:xsd location="classpath:examples.xsd"/>
+        <sws:xsd location="classpath:schemas/examples.xsd"/>
     </sws:dynamic-wsdl>
 
 
     <bean id="parent" class="org.springframework.xml.xsd.SimpleXsdSchema">
-        <property name="xsd" value="classpath:parent.xsd"/>
+        <property name="xsd" value="classpath:schemas/parent.xsd"/>
     </bean>
 
 
@@ -78,8 +93,8 @@
             class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
             <property name="schemas">
                 <list>
-                    <value>classpath:examples.xsd</value>
-                    <value>classpath:parent.xsd</value>
+                    <value>classpath:schemas/examples.xsd</value>
+                    <value>classpath:schemas/parent.xsd</value>
                 </list>
             </property>
             <property name="validateRequest" value="true"/>