Using maven-jaxb2-plugin
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Mon, 14 Dec 2015 03:19:31 +0000 (04:19 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Mon, 14 Dec 2015 03:19:31 +0000 (04:19 +0100)
35 files changed:
jaxb2/web-services-spring-jaxb2-client/pom.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/bindings/custombinding.xjb [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/main/resources/examples.xsd [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/pom.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java [new file with mode: 0644]
jaxb2/web-services-spring-jaxb2/pom.xml [new file with mode: 0644]

diff --git a/jaxb2/web-services-spring-jaxb2-client/pom.xml b/jaxb2/web-services-spring-jaxb2-client/pom.xml
new file mode 100644 (file)
index 0000000..a70061d
--- /dev/null
@@ -0,0 +1,184 @@
+<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>
+    <artifactId>web-services-spring-jaxb2</artifactId>
+    <groupId>de.spring.webservices</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>web-services-spring-jaxb2-client</artifactId>
+  <name>web-services-spring-jaxb2-client</name>
+  <url>http://gumartinm.name</url>
+
+  <properties>
+    <project.wsdl.sources.path>src/main/build-resources/wsdl</project.wsdl.sources.path>
+    <project.wsdl.target.path>${basedir}/target/generated-sources/src/main/java</project.wsdl.target.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>
+    <dependency>
+      <groupId>org.springframework.ws</groupId>
+      <artifactId>spring-ws-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.ws</groupId>
+      <artifactId>spring-xml</artifactId>
+    </dependency>
+    <dependency>
+        <groupId>org.jdom</groupId>
+        <artifactId>jdom</artifactId>
+    </dependency>
+
+
+    <!-- Global types -->
+    <dependency>
+        <groupId>de.spring.webservices</groupId>
+        <artifactId>web-services-spring-jaxb2-globalxsds</artifactId>
+        <version>${project.version}</version>
+    </dependency>
+
+
+    <!-- Required by spring-ws-core -->
+    <dependency>
+        <groupId>wsdl4j</groupId>
+        <artifactId>wsdl4j</artifactId>
+    </dependency>
+
+    <!-- Required by jaxb2-basics as specified: 
+         http://confluence.highsource.org/display/J2B/Using+JAXB2+Basics+Plugins+with+CXF
+    -->
+    <dependency>
+      <groupId>org.jvnet.jaxb2_commons</groupId>
+      <artifactId>jaxb2-basics-runtime</artifactId>
+      <version>0.9.4</version>
+    </dependency>
+
+    <!-- Unitary and integration tests -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.ws</groupId>
+      <artifactId>spring-ws-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <finalName>${project.artifactId}</finalName>
+    <resources>
+        <resource>
+            <directory>${basedir}/src/main/resources/</directory>
+            <includes>
+                <include>**/*.*</include>
+            </includes>
+        </resource>
+    </resources>
+    <plugins>
+        <!-- Generate code from wsdl files:
+             We could use maven-jaxb2-plugin in order to generate Java classes from WSDL files but
+             this plugin seems more useful so, I keep using it. Besides, it is based on Apache CXF which
+             as well, uses jaxb.
+
+             See: http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html
+        -->
+        <plugin>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-codegen-plugin</artifactId>
+            <version>3.1.0</version>
+            <executions>
+                <execution>
+                    <id>generate-sources-from-wsdl</id>
+                    <phase>generate-sources</phase>
+                    <goals>
+                        <goal>wsdl2java</goal>
+                    </goals>
+                    <configuration>
+                        <fork>true</fork>
+                        <sourceRoot>${project.wsdl.target.path}</sourceRoot>
+                        <wsdlOptions>
+                            <wsdlOption>
+                                <!--
+                                <wsdl>${project.wsdl.sources.path}/example.wsdl</wsdl>
+                                -->
+                                <wsdl>${project.wsdl.sources.path}/example.wsdl</wsdl>
+                                <bindingFiles>
+                                    <bindingFile>${project.bindings.path}/custombinding.xjb</bindingFile>
+                                </bindingFiles>
+                                <extraargs>
+                                    <extraarg>-xjc-Xinheritance</extraarg>
+                                    <extraarg>-xjc-Xannotate</extraarg>
+                                    <extraarg>-catalog</extraarg>
+                                    <extraarg>${project.catalogs.path}/catalog.cat</extraarg>
+                                    <extraarg>-verbose</extraarg>
+                                </extraargs>
+                            </wsdlOption>
+                        </wsdlOptions>
+                    </configuration>
+                 </execution>
+            </executions>
+            <dependencies>
+                 <!-- We make this plugin work with this jaxb2 version.
+                      This particular version let us generate inherited classes using
+                      the -Xinheritance argument.
+     
+                      DO NOT FORGET: We can use <inheritance:implements> in xsd files or by means 
+                      of custom bindings (see custombinding.xjb) This is useful when you may not modify
+                      xsd files because they are generated by other person or machine.
+                 -->
+                 <dependency>
+                     <groupId>org.jvnet.jaxb2_commons</groupId>
+                     <artifactId>jaxb2-basics</artifactId>
+                     <version>0.9.4</version>
+                 </dependency>
+
+                 <!-- We make this plugin work with this jaxb2 version.
+                      This particular version let us generate annotated classes using
+                      the -Xannotate argument.
+
+                      DO NOT FORGET: We can use <annox:annotate> in xsd files or by means 
+                      of custom bindings like I did with <inheritance:implements> (see custombinding.xjb)
+                      This is useful when you may not modify xsd files because they are generated
+                      by other person or machine.
+                 -->
+                 <dependency>
+                     <groupId>org.jvnet.jaxb2_commons</groupId>
+                     <artifactId>jaxb2-basics-annotate</artifactId>
+                     <version>1.0.1</version>
+                 </dependency>
+             </dependencies>
+        </plugin>
+        <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.9.1</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${project.wsdl.target.path}</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+          </plugin>
+    </plugins>
+  </build>
+</project>
+
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/bindings/custombinding.xjb b/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/bindings/custombinding.xjb
new file mode 100644 (file)
index 0000000..95e1fd2
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<jaxws:bindings
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
+    xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
+    xmlns:annox="http://annox.dev.java.net"
+    jaxb:version="2.1"
+    jaxb:extensionBindingPrefixes="xjc inheritance annox">
+
+    <jaxws:bindings
+        node="wsdl:definitions">
+        <jaxws:package name="de.spring.webservices.auto"/>
+    </jaxws:bindings>
+    
+
+    <!--
+        XSD namespace for included schema in WSDL: http://gumartinm.name/spring-ws/example
+
+        I am skiping the XSD namespace for imported schema in WSDL: http://gumartinm.name/spring-ws/parent because I guess,
+        there must be some way of using the already generated code in web-services-spring-globalxsds instead of generating new one
+        (perhaps using maven-jaxb2-plugin with episodes)
+     -->
+    <jaxws:bindings
+        node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://gumartinm.name/spring-ws/example']">
+
+        <jaxb:schemaBindings>
+            <jaxb:package name="de.spring.webservices.auto"/>
+        </jaxb:schemaBindings>
+
+        <jaxb:bindings node="//xs:element[@name='CustomBindingExampleRequest']/xs:complextype">
+            <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+            <annox:annotate>@java.lang.suppresswarnings({"unchecked","rawtypes"})</annox:annotate>
+        </jaxb:bindings>
+
+        <jaxb:bindings node="//xs:element[@name='CustomBindingExampleResponse']/xs:complextype">
+            <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+            <annox:annotate>@java.lang.suppresswarnings({"unchecked","rawtypes"})</annox:annotate>
+        </jaxb:bindings>
+
+        <jaxb:globalBindings>
+            <xjc:javaType adapter="de.spring.webservices.binders.XSDateTimeCustomBinder"
+                name="java.util.Date" xmlType="xs:dateTime" />
+        </jaxb:globalBindings>
+
+    </jaxws:bindings>
+
+</jaxws:bindings>
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat b/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat
new file mode 100644 (file)
index 0000000..4bc1c66
--- /dev/null
@@ -0,0 +1,38 @@
+<?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
+
+
+        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>
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl b/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl
new file mode 100644 (file)
index 0000000..02b2256
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://gumartinm.name/spring-ws/example" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://gumartinm.name/resource/wsdl/schemas" targetNamespace="http://gumartinm.name/resource/wsdl/schemas">
+  <wsdl:types>
+    <xs:schema xmlns:annox="http://annox.dev.java.net" xmlns:example="http://gumartinm.name/spring-ws/example" xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:parent="http://gumartinm.name/spring-ws/parent" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" jaxb:extensionBindingPrefixes="inheritance annox" jaxb:version="2.1" 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 maxOccurs="1" minOccurs="0" name="exampleDate" type="xs:dateTime"/>
+                <xs:element maxOccurs="1" minOccurs="0" 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 maxOccurs="1" minOccurs="0" name="exampleDate" type="xs:dateTime"/>
+                <xs:element maxOccurs="1" minOccurs="0" name="parentEnum" type="parent:parentEnumType"/>
+            </xs:all>
+        </xs:complexType>
+    </xs:element>
+
+       <!-- Example of creating array list by means of XSD -->
+    <xs:complexType name="car">
+       <xs:sequence>
+               <xs:element name="data" type="xs:string"/>
+               <xs:element maxOccurs="100" minOccurs="0" name="parentEnum" type="parent:parentEnumType"/>
+       </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="truck">
+       <xs:all>
+               <xs:element name="data" type="xs:string"/>
+               <xs:element maxOccurs="1" minOccurs="0" name="parentEnum" type="parent:parentEnumType"/>
+       </xs:all>
+    </xs:complexType>
+    <xs:element name="vehicles">
+        <xs:complexType>
+               <xs:sequence>
+                               <xs:element maxOccurs="unbounded" name="cars" type="example:car"/>
+                               <xs:element maxOccurs="100" minOccurs="0" name="trucks" type="example:truck"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+</xs:schema>
+  </wsdl:types>
+  <wsdl:message name="CustomBindingExampleRequest">
+    <wsdl:part element="sch:CustomBindingExampleRequest" name="CustomBindingExampleRequest">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="ExampleRequest">
+    <wsdl:part element="sch:ExampleRequest" name="ExampleRequest">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="ExampleResponse">
+    <wsdl:part element="sch:ExampleResponse" name="ExampleResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="CustomBindingExampleResponse">
+    <wsdl:part element="sch:CustomBindingExampleResponse" name="CustomBindingExampleResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="Examples">
+    <wsdl:operation name="CustomBindingExample">
+      <wsdl:input message="tns:CustomBindingExampleRequest" name="CustomBindingExampleRequest">
+    </wsdl:input>
+      <wsdl:output message="tns:CustomBindingExampleResponse" name="CustomBindingExampleResponse">
+    </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="Example">
+      <wsdl:input message="tns:ExampleRequest" name="ExampleRequest">
+    </wsdl:input>
+      <wsdl:output message="tns:ExampleResponse" name="ExampleResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="ExamplesSoap12" type="tns:Examples">
+    <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="CustomBindingExample">
+      <soap12:operation soapAction=""/>
+      <wsdl:input name="CustomBindingExampleRequest">
+        <soap12:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="CustomBindingExampleResponse">
+        <soap12:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="Example">
+      <soap12:operation soapAction=""/>
+      <wsdl:input name="ExampleRequest">
+        <soap12:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="ExampleResponse">
+        <soap12:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="ExamplesService">
+    <wsdl:port binding="tns:ExamplesSoap12" name="ExamplesSoap12">
+      <soap12:address location="http://localhost:8080/web-services-spring-server/spring-ws/example"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java b/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java
new file mode 100644 (file)
index 0000000..177c13e
--- /dev/null
@@ -0,0 +1,72 @@
+package de.spring.webservices.client;
+
+import name.gumartinm.spring_ws.parent.ParentEnumType;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ws.client.core.WebServiceTemplate;
+
+import de.spring.webservices.auto.CustomBindingExampleRequest;
+import de.spring.webservices.auto.CustomBindingExampleResponse;
+import de.spring.webservices.auto.ExampleRequest;
+import de.spring.webservices.auto.ExampleResponse;
+import de.spring.webservices.auto.Examples;
+import de.spring.webservices.auto.ExamplesService;
+
+/**
+ * Someone could write code like this one in order to send and receive
+ * information from our Web Services.
+ * 
+ */
+public class ExampleClientService {    
+    private final WebServiceTemplate webServiceTemplate;
+
+    @Autowired
+    public ExampleClientService(WebServiceTemplate webServiceTemplate) {
+           this.webServiceTemplate = webServiceTemplate;
+    }
+
+       public ExampleResponse sendAndReceiveJava() {
+        final ExampleRequest exampleRequest = new ExampleRequest();
+        exampleRequest.setData("SCARLETT JAVA. IT IS CANON.");
+
+        final Examples exampleService = new ExamplesService().getExamplesSoap12();
+        final ExampleResponse exampleResponse = exampleService.example(exampleRequest);
+        
+        return exampleResponse;
+    }
+    
+       public ExampleResponse sendAndReceiveSpring() {
+        final ExampleRequest exampleRequest = new ExampleRequest();
+        exampleRequest.setData("SCARLETT SPRING. IT IS CANON.");
+
+        final ExampleResponse exampleResponse = (ExampleResponse)
+                this.webServiceTemplate.marshalSendAndReceive(exampleRequest);
+        
+        return exampleResponse;
+    }
+       
+       public CustomBindingExampleResponse sendAndReceiveJavaCustom() {
+        final CustomBindingExampleRequest customBindingxampleRequest =
+                       new CustomBindingExampleRequest();
+        customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON.");
+        customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST);
+  
+        final Examples exampleService = new ExamplesService().getExamplesSoap12();
+        final CustomBindingExampleResponse customBindingExampleResponse =
+                exampleService.customBindingExample(customBindingxampleRequest);
+        
+        return customBindingExampleResponse;
+    }
+       
+       public CustomBindingExampleResponse sendAndReceiveSpringCustom() {
+        final CustomBindingExampleRequest customBindingxampleRequest =
+                       new CustomBindingExampleRequest();
+        customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON.");
+
+        final CustomBindingExampleResponse customBindingExampleResponse =
+                       (CustomBindingExampleResponse) this.webServiceTemplate
+                       .marshalSendAndReceive(customBindingxampleRequest);
+        
+        return customBindingExampleResponse;
+    }
+}
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java b/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java
new file mode 100644 (file)
index 0000000..48fbdcd
--- /dev/null
@@ -0,0 +1,52 @@
+package de.spring.webservices.client;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import de.spring.webservices.auto.CustomBindingExampleResponse;
+import de.spring.webservices.auto.ExampleResponse;
+
+/**
+ * This class is used just like a nice example about how to write and run client
+ * code which will send data to and from the Web Services.
+ * 
+ */
+public class MainTest {
+       private static final Logger logger = LoggerFactory.getLogger(MainTest.class);
+       
+    public ApplicationContext context;
+
+    /**
+     * @param args
+     */
+    public static void main(final String[] args) {
+        final MainTest test = new MainTest();
+
+        test.context = new ClassPathXmlApplicationContext(
+                "classpath:spring-configuration/ws/client-spring-configuration.xml");
+
+        final ExampleClientService example =
+                       (ExampleClientService) test.context.getBean("exampleClient");
+
+        logger.info("ExampleResponse Java:");
+        ExampleResponse response = example.sendAndReceiveJava();
+        logger.info(response.getData());
+        
+        
+        logger.info("CustomBindingExampleResponse Java:");
+        CustomBindingExampleResponse customBindingResponse = example.sendAndReceiveJavaCustom();
+        logger.info(customBindingResponse.getData());
+        
+        
+        logger.info("ExampleResponse Spring:");
+        response = example.sendAndReceiveSpring();
+        logger.info(response.getData());
+        
+        
+        logger.info("CustomBindingExampleResponse Spring:");
+        customBindingResponse = example.sendAndReceiveSpringCustom();
+        logger.info(customBindingResponse.getData());
+    }
+}
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/examples.xsd b/jaxb2/web-services-spring-jaxb2-client/src/main/resources/examples.xsd
new file mode 100644 (file)
index 0000000..96c3737
--- /dev/null
@@ -0,0 +1,92 @@
+<?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"
+    xmlns:example="http://gumartinm.name/spring-ws/example"
+    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" minOccurs="0" maxOccurs="1" />
+                <xs:element name="parentEnum" type="parent:parentEnumType" minOccurs="0" maxOccurs="1" />
+            </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" minOccurs="0" maxOccurs="1" />
+                <xs:element name="parentEnum" type="parent:parentEnumType" minOccurs="0" maxOccurs="1" />
+            </xs:all>
+        </xs:complexType>
+    </xs:element>
+
+       <!-- Example of creating array list by means of XSD -->
+    <xs:complexType name="car">
+       <xs:sequence>
+               <xs:element name="data" type="xs:string" />
+               <xs:element name="parentEnum" type="parent:parentEnumType" minOccurs="0" maxOccurs="100" />
+       </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="truck">
+       <xs:all>
+               <xs:element name="data" type="xs:string" />
+               <xs:element name="parentEnum" type="parent:parentEnumType" minOccurs="0" maxOccurs="1" />
+       </xs:all>
+    </xs:complexType>
+    <xs:element name="vehicles">
+        <xs:complexType>
+               <xs:sequence>
+                               <xs:element name="cars" type="example:car" maxOccurs="unbounded" />
+                               <xs:element name="trucks" type="example:truck" minOccurs="0" maxOccurs="100" />
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+</xs:schema>
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml b/jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml
new file mode 100644 (file)
index 0000000..18a4008
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="trace" strict="true"
+                name="XMLConfigTest" packages="org.apache.logging.log4j.test">
+    <Appenders>
+        <Appender type="Console" name="STDOUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
+        </Appender>
+    </Appenders>
+    <Loggers>
+        <Root level="trace">
+            <AppenderRef ref="STDOUT"/>
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml b/jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml
new file mode 100644 (file)
index 0000000..785d2db
--- /dev/null
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:sws="http://www.springframework.org/schema/web-services"
+    xmlns:oxm="http://www.springframework.org/schema/oxm" 
+    xmlns:aop="http://www.springframework.org/schema/aop"
+    xmlns:util="http://www.springframework.org/schema/util"
+
+    xsi:schemaLocation="http://www.springframework.org/schema/beans 
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/context 
+        http://www.springframework.org/schema/context/spring-context.xsd
+        http://www.springframework.org/schema/web-services 
+        http://www.springframework.org/schema/web-services/web-services.xsd
+        http://www.springframework.org/schema/oxm 
+        http://www.springframework.org/schema/oxm/spring-oxm.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+
+    <!-- 
+        This file is an example about how someone should write code in order to send and
+        receive data from the Web Services.
+    -->
+   
+    <!-- Searches for @Endpoint  --> 
+    <context:component-scan base-package="de.spring.webservices"/>
+
+    <oxm:jaxb2-marshaller id="marshaller" context-path="de.spring.webservices.auto"/>
+       
+    <!-- Searches for @PayloadRoot --> 
+    <sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller"/>
+     
+   
+    <!-- Required in order to use SOAP 1.2
+         id="messageFactory" is not a random choice, if you use another name it will not work
+         (Spring will end up loading SOAP 1.1)
+    -->
+    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
+        <property name="soapVersion">
+            <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12" />
+        </property>
+    </bean> 
+    
+    
+    <sws:interceptors>
+        <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor">
+            <property name="logRequest" value="true"/>
+            <property name="logResponse" value="true"/>
+        </bean>
+    </sws:interceptors>
+
+    <!-- 
+        Â¿Este validador funciona teniendo inheritance en el xsd? (inheritances es una cosa especial 
+        del JAXB2 que estoy usando para generar las clases desde el xsd)
+        Parece que el unmarshal (que supongo que se hace con el JAXB2 que está en el classpath
+        debido al tipo de Endpoint que estoy usando, que por cierto no sé cual JAXB2 está cogiendo realmente) 
+        funciona, así que supongo el validador tambien :/
+        Lo que realmente tampoco sé es si hay alguna relación entre los validadores y JAXB2 :/
+    -->
+    <bean id="payloadValidatingInterceptor" 
+        class="org.springframework.ws.client.support.interceptor.PayloadValidatingInterceptor">
+        <property name="schemas">
+            <list>
+                <value>classpath:examples.xsd</value>
+                <value>classpath:parent.xsd</value>
+            </list>
+        </property>
+        <property name="validateRequest" value="true"/>
+        <property name="validateResponse" value="true"/>
+    </bean>
+    
+
+    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
+        <constructor-arg ref="messageFactory"/>
+        <property name="marshaller" ref="marshaller" />
+        <property name="unmarshaller" ref="marshaller" />
+
+        <!-- For local deployments change to http://localhost:8080/web-services-spring-server/spring-ws/example -->
+        <property name="defaultUri" value="http://gumartinm.name/spring-ws/example"/>
+
+        <property name="interceptors">
+            <list>
+                <ref bean="payloadValidatingInterceptor" />
+            </list>
+        </property>
+    </bean>
+    
+    <bean id="exampleClient" class="de.spring.webservices.client.ExampleClientService">
+        <!--
+        @Autowired works even using XML configuration as long as you use context:component-scan
+        <property name="webServiceTemplate" ref="webServiceTemplate"/>
+        -->
+    </bean>
+    
+</beans>
diff --git a/jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java b/jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java
new file mode 100644 (file)
index 0000000..a536c47
--- /dev/null
@@ -0,0 +1,78 @@
+package de.spring.webservices.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.springframework.ws.test.client.RequestMatchers.payload;
+import static org.springframework.ws.test.client.ResponseCreators.withPayload;
+
+import javax.xml.transform.Source;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.ws.client.core.WebServiceTemplate;
+import org.springframework.ws.test.client.MockWebServiceServer;
+import org.springframework.xml.transform.StringSource;
+
+import de.spring.webservices.auto.CustomBindingExampleResponse;
+import de.spring.webservices.auto.ExampleResponse;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath*:spring-configuration/ws/client-spring-configuration.xml")
+public class ExampleClientServiceIntegrationTest {
+
+       @Autowired
+       ExampleClientService exampleClientService;
+       
+    @Autowired
+    private WebServiceTemplate webServiceTemplate;
+
+    private MockWebServiceServer mockServer;
+
+    @Before
+    public void createServer() throws Exception {
+        mockServer = MockWebServiceServer.createServer(webServiceTemplate);
+    }
+
+    @Test
+    public void customerClient() throws Exception {
+        final Source requestPayload = new StringSource(
+                "<ExampleRequest xmlns='http://gumartinm.name/spring-ws/example'>"
+                        + "<data>SCARLETT SPRING. IT IS CANON.</data>"
+                        + "</ExampleRequest>");
+        final Source responsePayload = new StringSource(
+                "<ns2:ExampleResponse xmlns:ns2='http://gumartinm.name/spring-ws/example'>"
+                        + "<ns2:data>SNAKE EYES AND SCARLETT SPRING. IT IS CANON.</ns2:data>"
+                        + "</ns2:ExampleResponse>");
+        mockServer.expect(payload(requestPayload)).andRespond(
+                withPayload(responsePayload));
+        
+        final ExampleResponse response = exampleClientService.sendAndReceiveSpring();
+
+        assertEquals(response.getData(), "SNAKE EYES AND SCARLETT SPRING. IT IS CANON.");
+        mockServer.verify();
+    }
+    
+    @Test
+    public void customerCustomClient() throws Exception { 
+        final Source customRequestPayload = new StringSource(
+                "<CustomBindingExampleRequest xmlns='http://gumartinm.name/spring-ws/example'>" +
+                        "<data>CUSTOM BINDING SPRING. SCARLETT. IT IS CANON.</data>" +
+                "</CustomBindingExampleRequest>");
+        final Source customResponsePayload = new StringSource(
+                "<ns2:CustomBindingExampleResponse xmlns:ns2='http://gumartinm.name/spring-ws/example'>" +
+                        "<ns2:data>CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON.</ns2:data>" +
+                "</ns2:CustomBindingExampleResponse>");
+        mockServer.expect(payload(customRequestPayload)).andRespond(
+                       withPayload(customResponsePayload));
+        
+        final CustomBindingExampleResponse response = exampleClientService.sendAndReceiveSpringCustom();
+
+        assertEquals(response.getData(), "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON.");
+        mockServer.verify();
+    }
+}
+
diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml b/jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml
new file mode 100644 (file)
index 0000000..b577d57
--- /dev/null
@@ -0,0 +1,102 @@
+<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>
+               <artifactId>web-services-spring-jaxb2</artifactId>
+               <groupId>de.spring.webservices</groupId>
+               <version>1.0-SNAPSHOT</version>
+       </parent>
+       <artifactId>web-services-spring-jaxb2-globalxsds</artifactId>
+       <name>web-services-spring-jaxb2-globalxsds</name>
+       <url>http://gumartinm.name</url>
+
+       <properties>
+               <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>
+
+               <!-- Unitary and integration tests -->
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+
+       <build>
+               <finalName>${project.artifactId}</finalName>
+               <resources>
+                       <resource>
+                               <directory>${basedir}/src/main/resources</directory>
+                               <includes>
+                                       <include>**/*.*</include>
+                               </includes>
+                       </resource>
+               </resources>
+               <plugins>
+                       <plugin>
+                               <groupId>org.jvnet.jaxb2.maven2</groupId>
+                               <artifactId>maven-jaxb2-plugin</artifactId>
+                               <version>0.13.1</version>
+                               <executions>
+                                       <execution>
+                                               <id>generate-sources-from-xsd</id>
+                                               <goals>
+                                                       <goal>generate</goal>
+                                               </goals>
+                                               <phase>generate-sources</phase>
+                                       </execution>
+                               </executions>
+                               <configuration>
+                                       <!-- Specifies the schema directory, src/main/resources by default. -->
+                                       <schemaDirectory>${project.xsd.schemas.source.path}</schemaDirectory>
+
+                                       <!-- Specifies the binding directory, default to the schemaDirectory -->
+                                       <bindingDirectory>${project.bindings.path}</bindingDirectory>
+                                       <!-- Do not scan for *.xjb files in dependencies -->
+                                       <scanDependenciesForBindings>false</scanDependenciesForBindings>
+
+                                       <!-- Target directory for the generated code, target/generated-sources/xjc 
+                                               by default. -->
+                                       <generateDirectory>${project.xsd.schemas.target.path}</generateDirectory>
+
+                                       <!-- The generated classes will all be placed under this Java package 
+                                               (XJC's -p option), unless otherwise specified in the schemas. If left unspecified, 
+                                               the package will be derived from the schemas only. -->
+                                       <generatePackage>${project.xsd.schemas.package.name}</generatePackage>
+
+                                       <!-- I don't think I need the next two options because mvn clean should 
+                                               make the trick, anyhow, I am using them. If true, the generateDirectory will 
+                                               be deleted before the XJC binding compiler recompiles the source files. Default 
+                                               is false. -->
+                                       <removeOldOutput>true</removeOldOutput>
+                                       <!-- If true (default), package directories will be cleaned before the 
+                                               XJC binding compiler generates the source files. -->
+                                       <cleanPackageDirectories>true</cleanPackageDirectories>
+
+                                       <!-- Encoding for the generated sources, defaults to ${project.build.sourceEncoding}. -->
+                                       <encoding>${project.build.sourceEncoding}</encoding>
+
+                                       <!-- Locale used during generation, for instance en, de, fr etc. This 
+                                               will, for instance, influence the language of the generated JavaDoc comments. -->
+                                       <locale>en</locale>
+
+                                       <!-- This nice configuration avoids to use build-helper-maven-plugin -->
+                                       <addCompileSourceRoot>true</addCompileSourceRoot>
+                                       <addTestCompileSourceRoot>false</addTestCompileSourceRoot>
+
+                                       <!-- 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>
+
+                                       <verbose>true</verbose>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+</project>
diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb
new file mode 100644 (file)
index 0000000..8b4a110
--- /dev/null
@@ -0,0 +1,8 @@
+<?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"
+    jaxb:version="2.1"
+    jaxb:extensionBindingPrefixes="">
+    
+</jaxb:bindings>
diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java
new file mode 100644 (file)
index 0000000..f39921a
--- /dev/null
@@ -0,0 +1,35 @@
+package de.spring.webservices.binders;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+
+/**
+ * ATTENTION: if you are using this custombinder you will have to create custom payload
+ * validators for Spring (AS FAR AS I KNOW)
+ *
+ */
+public class XSDateTimeCustomBinder extends XmlAdapter<String, Date> {
+
+       @Override
+    public Date unmarshal(final String dateTime) throws Exception {
+               // X pattern just works from Java >= 1.7
+               final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
+               formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid"));
+
+               return formatter.parse(dateTime);
+    }
+
+       @Override
+    public String marshal(final Date dateTime) throws Exception {
+               // X pattern just works from Java >= 1.7
+               final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
+               formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid"));
+               
+               return formatter.format(dateTime);
+    }
+}
diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java
new file mode 100644 (file)
index 0000000..13b5113
--- /dev/null
@@ -0,0 +1,111 @@
+package de.spring.webservices.operations;
+
+/**
+ * <p>
+ * Operations: WSDL v1.1 and v2.0 
+ * </p>
+ * See: <a href="http://www.w3.org/TR/wsdl#_porttypes">http://www.w3.org/TR/wsdl#_porttypes</a><br>
+ * See: <a href="http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns">
+ * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns</a>
+ * 
+ */
+public interface Operations {
+
+    /**
+     * <p>
+     * Request-response operation WSDL v1.1
+     * </p>
+     * See: <a
+     * href="http://www.w3.org/TR/wsdl#_request-response">http://www.w3.org
+     * /TR/wsdl#_request-response</a>
+     * 
+     * @param <T>
+     *            Describes {@link Response}
+     * @param <E>
+     *            Describes {@link Request}
+     */
+    public static interface RequestResponse<T extends Response, E extends Request> {
+        T requestResponse(E request);
+    }
+
+    /**
+     * <p>
+     * One-way operation WSDL v1.1
+     * </p>
+     * See: <a
+     * href="http://www.w3.org/TR/wsdl#_one-way">http://www.w3.org/TR/wsdl
+     * #_one-way</a>
+     * 
+     * @param <T>
+     *            Describes {@link Response}
+     * @param <E>
+     *            Describes {@link Request}
+     */
+    public interface OneWay<E extends Request> {
+        void oneWay(E request);
+    }
+
+    /**
+     * <p>
+     * Notification operation WSDL v1.1
+     * </p>
+     * See: <a
+     * href="http://www.w3.org/TR/wsdl#_notification">http://www.w3.org/TR
+     * /wsdl#_notification</a>
+     * 
+     * @param <T>
+     *            Describes {@link Response}
+     * @param <E>
+     *            Describes {@link Request}
+     */
+    public interface Notification<T extends Response> {
+        T notification();
+    }
+
+    /**
+     * <p>
+     * In-Only message exchange pattern WSDL 2.0
+     * </p>
+     * See: <a
+     * href="http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns">
+     * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns</a>
+     * 
+     * @param <E> 
+     *             Describes {@link Request}
+     */
+    public interface InOnly<E extends Request> {
+        void inOnly(E request);
+    }
+
+    /**
+     * <p>
+     * Robust In-Only message exchange pattern WSDL 2.0
+     * </p>
+     * See: <a
+     * href="http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns">
+     * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns</a>
+     * 
+     * @param <E> 
+     *             Describes {@link Request}
+     */
+    public interface RobustInOnly<E extends Request> {
+        void robustInOnly(E request);
+    }
+
+    /**
+     * <p>
+     * In-Out message exchange pattern WSDL 2.0
+     * </p>
+     * See: <a
+     * href="http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns">
+     * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns</a>
+     * 
+     * @param <T>
+     *            Describes {@link Response}
+     * @param <E>
+     *            Describes {@link Request}
+     */
+    public interface InOut<T extends Response, E extends Request> {
+        T inOut(E request);
+    }
+}
\ No newline at end of file
diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java
new file mode 100644 (file)
index 0000000..77d81f4
--- /dev/null
@@ -0,0 +1,5 @@
+package de.spring.webservices.operations;
+
+public interface Request {
+
+}
diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java
new file mode 100644 (file)
index 0000000..3a2cbea
--- /dev/null
@@ -0,0 +1,5 @@
+package de.spring.webservices.operations;
+
+public interface Response {
+
+}
diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd
new file mode 100644 (file)
index 0000000..0ce508e
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    elementFormDefault="qualified"
+    targetNamespace="http://gumartinm.name/spring-ws/parent">
+       
+    <xs:simpleType name="parentEnumType">
+        <xs:restriction base="xs:token">
+            <xs:enumeration value="FIRST"/>
+            <xs:enumeration value="SECOND"/>
+            <xs:enumeration value="THIRD"/>
+            <xs:enumeration value="FOURTH"/>
+            <xs:enumeration value="FIVETH"/>
+        </xs:restriction>
+    </xs:simpleType>
+
+</xs:schema>
diff --git a/jaxb2/web-services-spring-jaxb2-server/pom.xml b/jaxb2/web-services-spring-jaxb2-server/pom.xml
new file mode 100644 (file)
index 0000000..b12472a
--- /dev/null
@@ -0,0 +1,199 @@
+<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>
+               <artifactId>web-services-spring-jaxb2</artifactId>
+               <groupId>de.spring.webservices</groupId>
+               <version>1.0-SNAPSHOT</version>
+       </parent>
+       <artifactId>web-services-spring-jaxb2-server</artifactId>
+       <packaging>war</packaging>
+       <name>web-services-spring-jaxb2-server</name>
+       <url>http://gumartinm.name</url>
+
+       <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>
+               <dependency>
+                       <groupId>org.springframework.ws</groupId>
+                       <artifactId>spring-ws-core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework.ws</groupId>
+                       <artifactId>spring-xml</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.jdom</groupId>
+                       <artifactId>jdom</artifactId>
+               </dependency>
+
+
+               <!-- Global types -->
+               <dependency>
+                       <groupId>de.spring.webservices</groupId>
+                       <artifactId>web-services-spring-jaxb2-globalxsds</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+
+
+               <!-- Required by spring-ws-core -->
+               <dependency>
+                       <groupId>wsdl4j</groupId>
+                       <artifactId>wsdl4j</artifactId>
+               </dependency>
+
+               <!-- Unitary and integration tests -->
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-test</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework.ws</groupId>
+                       <artifactId>spring-ws-test</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-core</artifactId>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+
+       <build>
+               <finalName>${project.artifactId}</finalName>
+               <resources>
+                       <resource>
+                               <directory>${basedir}/src/main/webapp</directory>
+                               <excludes>
+                                       <exclude>**/*.*</exclude>
+                               </excludes>
+                       </resource>
+                       <resource>
+                               <directory>${basedir}/src/main/resources/</directory>
+                               <includes>
+                                       <include>**/*.*</include>
+                               </includes>
+                       </resource>
+               </resources>
+               <plugins>
+                       <plugin>
+                               <groupId>org.jvnet.jaxb2.maven2</groupId>
+                               <artifactId>maven-jaxb2-plugin</artifactId>
+                               <version>0.13.1</version>
+                               <executions>
+                                       <execution>
+                                               <id>generate-sources-from-xsd</id>
+                                               <goals>
+                                                       <goal>generate</goal>
+                                               </goals>
+                                               <phase>generate-sources</phase>
+                                       </execution>
+                               </executions>
+                               <configuration>
+                                       <!-- Specifies the schema directory, src/main/resources by default. -->
+                                       <schemaDirectory>${project.xsd.schemas.source.path}</schemaDirectory>
+
+                                       <!-- Specifies the binding directory, default to the schemaDirectory -->
+                                       <bindingDirectory>${project.bindings.path}</bindingDirectory>
+                                       <!-- Do not scan for *.xjb files in dependencies -->
+                                       <scanDependenciesForBindings>false</scanDependenciesForBindings>
+
+                                       <!-- Target directory for the generated code, target/generated-sources/xjc 
+                                               by default. -->
+                                       <generateDirectory>${project.xsd.schemas.target.path}</generateDirectory>
+
+                                       <!-- The generated classes will all be placed under this Java package 
+                                               (XJC's -p option), unless otherwise specified in the schemas. If left unspecified, 
+                                               the package will be derived from the schemas only. -->
+                                       <generatePackage>${project.xsd.schemas.package.name}</generatePackage>
+
+                                       <!-- I don't think I need the next two options because mvn clean should 
+                                               make the trick, anyhow, I am using them. If true, the generateDirectory will 
+                                               be deleted before the XJC binding compiler recompiles the source files. Default 
+                                               is false. -->
+                                       <removeOldOutput>true</removeOldOutput>
+                                       <!-- If true (default), package directories will be cleaned before the 
+                                               XJC binding compiler generates the source files. -->
+                                       <cleanPackageDirectories>true</cleanPackageDirectories>
+
+                                       <!-- Encoding for the generated sources, defaults to ${project.build.sourceEncoding}. -->
+                                       <encoding>${project.build.sourceEncoding}</encoding>
+
+                                       <!-- Locale used during generation, for instance en, de, fr etc. This 
+                                               will, for instance, influence the language of the generated JavaDoc comments. -->
+                                       <locale>en</locale>
+
+                                       <!-- This nice configuration avoids to use build-helper-maven-plugin -->
+                                       <addCompileSourceRoot>true</addCompileSourceRoot>
+                                       <addTestCompileSourceRoot>false</addTestCompileSourceRoot>
+
+                                       <!-- 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>
+
+                                       <verbose>true</verbose>
+
+                                       <extension>true</extension>
+                                       <args>
+                                               <arg>-Xinheritance</arg>
+                                               <arg>-Xannotate</arg>
+                                       </args>
+                                       <plugins>
+                                               <plugin>
+                                                       <groupId>org.jvnet.jaxb2_commons</groupId>
+                                                       <artifactId>jaxb2-basics</artifactId>
+                                                       <version>0.9.5</version>
+                                               </plugin>
+                                               <plugin>
+                                                       <groupId>org.jvnet.jaxb2_commons</groupId>
+                                                       <artifactId>jaxb2-basics-annotate</artifactId>
+                                                       <version>1.0.2</version>
+                                               </plugin>
+                                       </plugins>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-war-plugin</artifactId>
+                               <version>2.6</version>
+                               <configuration>
+                                       <webResources>
+                                               <resource>
+                                                       <filtering>true</filtering>
+                                                       <directory>src/main/webapp</directory>
+                                                       <includes>
+                                                               <include>WEB-INF/web.xml</include>
+                                                       </includes>
+                                               </resource>
+                                       </webResources>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.eclipse.jetty</groupId>
+                               <artifactId>jetty-maven-plugin</artifactId>
+                               <version>${jetty.version}</version>
+                               <configuration>
+                                       <jettyXml>${basedir}/src/main/jetty/jetty-http.xml</jettyXml>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+</project>
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb b/jaxb2/web-services-spring-jaxb2-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/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat b/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat
new file mode 100644 (file)
index 0000000..4bc1c66
--- /dev/null
@@ -0,0 +1,38 @@
+<?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
+
+
+        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>
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java
new file mode 100644 (file)
index 0000000..8fb4e40
--- /dev/null
@@ -0,0 +1,57 @@
+package de.spring.webservices.endpoints;
+
+import org.jdom2.Element;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ws.context.MessageContext;
+import org.springframework.ws.server.endpoint.annotation.Endpoint;
+import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
+import org.springframework.ws.server.endpoint.annotation.RequestPayload;
+import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
+
+import de.spring.webservices.auto.CustomBindingExampleRequest;
+import de.spring.webservices.auto.CustomBindingExampleResponse;
+import de.spring.webservices.auto.ExampleRequest;
+import de.spring.webservices.auto.ExampleResponse;
+import de.spring.webservices.operations.Operations;
+import de.spring.webservices.operations.Operations.RequestResponse;
+import de.spring.webservices.services.ExampleService;
+
+
+@Endpoint
+public class ExampleEndPoint {
+    private static final String NAMESPACE_URI = "http://gumartinm.name/spring-ws/example";
+    
+    private final Operations.RequestResponse
+       <CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExampleService;  
+    
+    private final ExampleService exampleService;
+    
+    @Autowired
+       public ExampleEndPoint(
+            RequestResponse<CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExampleService,
+            ExampleService exampleService) {
+           this.customBindingExampleService = customBindingExampleService;
+           this.exampleService = exampleService;
+    }
+       
+    @PayloadRoot(localPart = "ExampleRequest", namespace = NAMESPACE_URI)
+    @ResponsePayload
+    public ExampleResponse exampleResponse(
+            @RequestPayload final ExampleRequest request,
+            @RequestPayload final Element element,
+            final MessageContext messageContext) {
+
+        return this.exampleService.doResponse(request);
+    }
+    
+    @PayloadRoot(localPart = "CustomBindingExampleRequest", namespace = NAMESPACE_URI)
+    @ResponsePayload
+    public CustomBindingExampleResponse cuntomBindingExampleResponse(
+            @RequestPayload final CustomBindingExampleRequest requestObject,
+            @RequestPayload final Element element,
+            final MessageContext messageContext) {
+
+        return this.customBindingExampleService.requestResponse(requestObject);
+    }
+}
+
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java
new file mode 100644 (file)
index 0000000..9d7eb79
--- /dev/null
@@ -0,0 +1,11 @@
+package de.spring.webservices.services;
+
+import de.spring.webservices.auto.ExampleRequest;
+import de.spring.webservices.auto.ExampleResponse;
+
+
+public interface ExampleService {
+       
+       public ExampleResponse doResponse(ExampleRequest request);
+
+}
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java
new file mode 100644 (file)
index 0000000..caa7e41
--- /dev/null
@@ -0,0 +1,27 @@
+package de.spring.webservices.services.impl;
+
+import org.springframework.stereotype.Service;
+
+import de.spring.webservices.auto.CustomBindingExampleRequest;
+import de.spring.webservices.auto.CustomBindingExampleResponse;
+import de.spring.webservices.auto.ParentEnumType;
+import de.spring.webservices.operations.Operations;
+
+
+@Service("customBindingExampleService")
+public class CustomBindingExampleServiceImpl implements
+       Operations.RequestResponse<CustomBindingExampleResponse, CustomBindingExampleRequest> {
+
+       
+       @Override
+    public CustomBindingExampleResponse requestResponse(final CustomBindingExampleRequest request) {
+               
+        CustomBindingExampleResponse response = new CustomBindingExampleResponse();
+
+        response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData());
+        response.setParentEnum(ParentEnumType.FIRST);
+
+        return response;
+    }
+
+}
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java
new file mode 100644 (file)
index 0000000..7037776
--- /dev/null
@@ -0,0 +1,23 @@
+package de.spring.webservices.services.impl;
+
+import org.springframework.stereotype.Service;
+
+import de.spring.webservices.auto.ExampleRequest;
+import de.spring.webservices.auto.ExampleResponse;
+import de.spring.webservices.services.ExampleService;
+
+
+@Service("exampleService")
+public class ExampleServiceImpl implements ExampleService {
+       
+       @Override
+    public ExampleResponse doResponse(final ExampleRequest request) {
+               
+               ExampleResponse response = new ExampleResponse();
+
+        response.setData("SNAKE EYES AND " + request.getData());
+
+        return response;
+    }
+
+}
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml
new file mode 100644 (file)
index 0000000..d995630
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
+
+<!-- ============================================================= -->
+<!-- Configure the Jetty Server instance with an ID "Server"       -->
+<!-- by adding a HTTP connector.                                   -->
+<!-- This configuration must be used in conjunction with jetty.xml -->
+<!-- ============================================================= -->
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+
+ <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
+  <Set name="secureScheme">https</Set>
+  <Set name="securePort">
+    <Property name="jetty.secure.port" default="8443" />
+  </Set>
+  <Set name="outputBufferSize">32768</Set>
+  <Set name="requestHeaderSize">8192</Set>
+  <Set name="responseHeaderSize">8192</Set>
+  <Set name="sendServerVersion">true</Set>
+  <Set name="sendDateHeader">false</Set>
+  <Set name="headerCacheSize">512</Set>
+
+  <!-- Uncomment to enable handling of X-Forwarded- style headers
+  <Call name="addCustomizer">
+    <Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
+  </Call>
+  -->
+ </New>
+
+
+  <!-- =========================================================== -->
+  <!-- Add a HTTP Connector.                                       -->
+  <!-- Configure an o.e.j.server.ServerConnector with a single     -->
+  <!-- HttpConnectionFactory instance using the common httpConfig  -->
+  <!-- instance defined in jetty.xml                               -->
+  <!--                                                             -->
+  <!-- Consult the javadoc of o.e.j.server.ServerConnector and     -->
+  <!-- o.e.j.server.HttpConnectionFactory for all configuration    -->
+  <!-- that may be set here.                                       -->
+  <!-- =========================================================== -->
+  <Call name="addConnector">
+    <Arg>
+      <New class="org.eclipse.jetty.server.ServerConnector">
+        <Arg name="server">
+            <Ref refid="Server" />
+        </Arg>
+        <Arg name="factories">
+          <Array type="org.eclipse.jetty.server.ConnectionFactory">
+            <Item>
+              <New class="org.eclipse.jetty.server.HttpConnectionFactory">
+                <Arg name="config">
+                  <Ref refid="httpConfig" />
+                </Arg>
+              </New>
+            </Item>
+          </Array>
+        </Arg>
+        <Set name="host">
+          <Property name="jetty.host" default="127.0.0.1"/>
+        </Set>
+        <Set name="port">
+          <Property name="jetty.port" default="8080" />
+        </Set>
+        <Set name="idleTimeout">
+          <Property name="http.timeout" default="30000"/>
+        </Set>
+      </New>
+    </Arg>
+  </Call>
+
+</Configure>
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml
new file mode 100644 (file)
index 0000000..18a4008
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="trace" strict="true"
+                name="XMLConfigTest" packages="org.apache.logging.log4j.test">
+    <Appenders>
+        <Appender type="Console" name="STDOUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
+        </Appender>
+    </Appenders>
+    <Loggers>
+        <Root level="trace">
+            <AppenderRef ref="STDOUT"/>
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd b/jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd
new file mode 100644 (file)
index 0000000..96c3737
--- /dev/null
@@ -0,0 +1,92 @@
+<?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"
+    xmlns:example="http://gumartinm.name/spring-ws/example"
+    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" minOccurs="0" maxOccurs="1" />
+                <xs:element name="parentEnum" type="parent:parentEnumType" minOccurs="0" maxOccurs="1" />
+            </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" minOccurs="0" maxOccurs="1" />
+                <xs:element name="parentEnum" type="parent:parentEnumType" minOccurs="0" maxOccurs="1" />
+            </xs:all>
+        </xs:complexType>
+    </xs:element>
+
+       <!-- Example of creating array list by means of XSD -->
+    <xs:complexType name="car">
+       <xs:sequence>
+               <xs:element name="data" type="xs:string" />
+               <xs:element name="parentEnum" type="parent:parentEnumType" minOccurs="0" maxOccurs="100" />
+       </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="truck">
+       <xs:all>
+               <xs:element name="data" type="xs:string" />
+               <xs:element name="parentEnum" type="parent:parentEnumType" minOccurs="0" maxOccurs="1" />
+       </xs:all>
+    </xs:complexType>
+    <xs:element name="vehicles">
+        <xs:complexType>
+               <xs:sequence>
+                               <xs:element name="cars" type="example:car" maxOccurs="unbounded" />
+                               <xs:element name="trucks" type="example:truck" minOccurs="0" maxOccurs="100" />
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+</xs:schema>
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml
new file mode 100644 (file)
index 0000000..7341c77
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:context="http://www.springframework.org/schema/context"
+  xmlns:util="http://www.springframework.org/schema/util"
+
+  xsi:schemaLocation="http://www.springframework.org/schema/beans 
+                      http://www.springframework.org/schema/beans/spring-beans.xsd
+                      http://www.springframework.org/schema/context 
+                      http://www.springframework.org/schema/context/spring-context.xsd
+                      http://www.springframework.org/schema/util 
+                      http://www.springframework.org/schema/util/spring-util.xsd">
+
+</beans>
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml
new file mode 100644 (file)
index 0000000..afabf4e
--- /dev/null
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:context="http://www.springframework.org/schema/context"
+  xmlns:sws="http://www.springframework.org/schema/web-services"
+  xmlns:util="http://www.springframework.org/schema/util"
+
+  xsi:schemaLocation="http://www.springframework.org/schema/beans 
+                      http://www.springframework.org/schema/beans/spring-beans.xsd
+                      http://www.springframework.org/schema/web-services 
+                      http://www.springframework.org/schema/web-services/web-services.xsd
+                      http://www.springframework.org/schema/context 
+                      http://www.springframework.org/schema/context/spring-context.xsd
+                      http://www.springframework.org/schema/util 
+                      http://www.springframework.org/schema/util/spring-util.xsd">
+
+       <!-- Searches for @Endpoint  --> 
+    <context:component-scan base-package="de.spring.webservices"/>
+
+    <!--
+        Aqui se podría especificar un unmarshaller (para la request) o un
+        marshaller (para la response) especifico. Por ejemplo Castor.
+        
+        Por la anotacion que uso para el EndPoint y porque tengo JAXB2 en el
+        classpath, Spring lo que está haciendo es el equivalente a si se 
+        escribiera lo siguiente:
+        
+        <oxm:jaxb2-marshaller id="marshaller" context-path="de.spring.webservices.auto"/>
+        
+         Searches for @PayloadRoot
+        <sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller"/>
+     -->
+    <sws:annotation-driven/>
+
+    <!--
+        Spring makes the WSDL file for us from the XSD file.
+        Launch the Jetty server and download WSDL file from this URL:
+        http://localhost:8080/web-services-spring-server/spring-ws/example/example.wsdl
+    -->
+    <sws:dynamic-wsdl id="example" portTypeName="Examples"
+        createSoap12Binding="true" createSoap11Binding="false"
+        locationUri="/spring-ws/example"
+        targetNamespace="http://gumartinm.name/resource/wsdl/schemas">
+        <sws:xsd location="classpath:examples.xsd"/>
+    </sws:dynamic-wsdl>
+
+
+    <bean id="parent" class="org.springframework.xml.xsd.SimpleXsdSchema">
+        <property name="xsd" value="classpath:parent.xsd"/>
+    </bean>
+
+
+    <!-- Required in order to use SOAP 1.2
+        id="messageFactory" is not a random choice, if you use another name it will not work
+        (Spring will end up loading SOAP 1.1)
+    -->
+    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
+        <property name="soapVersion">
+            <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12" />
+        </property>
+    </bean>
+    
+    <sws:interceptors>
+        <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor">
+            <property name="logRequest" value="true"/>
+            <property name="logResponse" value="true"/>
+        </bean>
+
+        <!-- 
+            Â¿Este validador funciona teniendo inheritance en el xsd? (inheritances es una cosa especial 
+            del JAXB2 que estoy usando para generar las clases desde el xsd)
+            Parece que el unmarshal (que supongo que se hace con el JAXB2 que está en el classpath
+            debido al tipo de Endpoint que estoy usando, que por cierto no sé cual JAXB2 está cogiendo realmente) 
+            funciona, así que supongo el validador tambien :/
+            Lo que realmente tampoco sé es si hay alguna relación entre los validadores y JAXB2 :/
+        -->
+        <bean id="validatingInterceptor" 
+            class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
+            <property name="schemas">
+                <list>
+                    <value>classpath:examples.xsd</value>
+                    <value>classpath:parent.xsd</value>
+                </list>
+            </property>
+            <property name="validateRequest" value="true"/>
+            <property name="validateResponse" value="true"/>
+        </bean>
+    </sws:interceptors>
+    
+   
+    <bean id="exceptionResolver"
+        class="org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver">
+        <property name="defaultFault" value="SERVER"/>
+        <property name="exceptionMappings">
+            <value>
+                org.springframework.oxm.ValidationFailureException=CLIENT,Invalid request
+            </value>
+        </property>
+    </bean>
+    
+</beans>
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..7e14eba
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+
+    <display-name>Spring Web Services: example</display-name>
+
+    <listener>
+        <listener-class>
+            org.springframework.web.context.ContextLoaderListener
+        </listener-class>
+    </listener>
+
+    <context-param>
+        <param-name>spring.profiles.active</param-name>
+        <param-value>${environment.profile}</param-value>
+        <param-name>contextConfigLocation</param-name>
+        <param-value>
+            classpath*:spring-configuration/*.xml
+        </param-value>
+    </context-param>
+
+    <!-- Spring SOAP servlet -->
+    <servlet>
+        <servlet-name>spring-ws</servlet-name>
+        <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+        <async-supported>true</async-supported>
+        <init-param>
+            <param-name>contextConfigLocation</param-name>
+            <param-value>classpath*:spring-configuration/ws/*.xml</param-value>
+        </init-param>
+        <init-param>
+            <param-name>transformWsdlLocations</param-name>
+            <param-value>true</param-value>
+        </init-param>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>spring-ws</servlet-name>
+        <url-pattern>/spring-ws/*</url-pattern>
+    </servlet-mapping>
+
+</web-app>
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java b/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java
new file mode 100644 (file)
index 0000000..f0204cb
--- /dev/null
@@ -0,0 +1,62 @@
+package de.spring.webservices.endpoints;
+
+import static org.springframework.ws.test.server.RequestCreators.withPayload;
+import static org.springframework.ws.test.server.ResponseMatchers.payload;
+
+import javax.xml.transform.Source;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.ws.test.server.MockWebServiceClient;
+import org.springframework.xml.transform.StringSource;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath*:spring-configuration/ws/soap-ws.xml" } )
+public class ExampleEndPointIntegrationTest {
+
+    @Autowired
+    private ApplicationContext applicationContext;
+
+    private MockWebServiceClient mockClient;
+
+    @Before
+    public void createClient() {
+        mockClient = MockWebServiceClient.createClient(applicationContext);
+    }
+
+    @Test
+    public void exampleEndpoint() throws Exception {
+        final Source requestPayload = new StringSource(
+                "<ExampleRequest xmlns='http://gumartinm.name/spring-ws/example'>" +
+                        "<data>SCARLETT</data>" +
+                "</ExampleRequest>");
+        final Source responsePayload = new StringSource(
+                "<ns2:ExampleResponse xmlns:ns2='http://gumartinm.name/spring-ws/example'>" +
+                        "<ns2:data>SNAKE EYES AND SCARLETT</ns2:data>" +
+                "</ns2:ExampleResponse>");
+        mockClient.sendRequest(withPayload(requestPayload)).andExpect(
+                payload(responsePayload));
+        
+
+        final Source customRequestPayload = new StringSource(
+                "<CustomBindingExampleRequest xmlns='http://gumartinm.name/spring-ws/example'>" +
+                        "<data>SCARLETT</data>" +
+                               "<exampleDate>2015-06-03T10:20:30Z</exampleDate>" +
+                        "<parentEnum>FIRST</parentEnum>" +
+                "</CustomBindingExampleRequest>");
+        final Source customResponsePayload = new StringSource(
+                "<ns2:CustomBindingExampleResponse xmlns:ns2='http://gumartinm.name/spring-ws/example'>" +
+                        "<ns2:data>CUSTOM BINDING SNAKE EYES AND SCARLETT</ns2:data>" +
+                        "<ns2:parentEnum>FIRST</ns2:parentEnum>" +
+                "</ns2:CustomBindingExampleResponse>");
+        mockClient.sendRequest(withPayload(customRequestPayload)).andExpect(
+                payload(customResponsePayload));
+    }
+}
+
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java b/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java
new file mode 100644 (file)
index 0000000..5b04c2f
--- /dev/null
@@ -0,0 +1,52 @@
+package de.spring.webservices.endpoints;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import de.spring.webservices.auto.CustomBindingExampleRequest;
+import de.spring.webservices.auto.CustomBindingExampleResponse;
+import de.spring.webservices.auto.ExampleRequest;
+import de.spring.webservices.operations.Operations;
+import de.spring.webservices.services.ExampleService;
+
+
+public class ExampleEndPointTest {
+       
+       private ExampleService exampleService;
+       
+       private Operations.RequestResponse
+       <CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExampleService;
+       
+       private ExampleEndPoint exampleEndPoint;
+
+       @Before
+    public void init() {
+               exampleService = mock(ExampleService.class);
+               customBindingExampleService = mock(Operations.RequestResponse.class);
+               exampleEndPoint = new ExampleEndPoint(customBindingExampleService, exampleService);
+       }
+       
+       @Test
+       public void givenExampleRequestThenInvokeExampleService() {
+               ExampleRequest request = new ExampleRequest();
+               request.setData("SCARLETT");
+        
+               exampleEndPoint.exampleResponse(request, null, null);
+               
+               verify(exampleService).doResponse(request);
+       }
+       
+       @Test
+       public void givenCustomBindingExampleRequestThenInvokeCustomBindingExampleService() {
+               CustomBindingExampleRequest request = new CustomBindingExampleRequest();
+               request.setData("SCARLETT");
+        
+               exampleEndPoint.cuntomBindingExampleResponse(request, null, null);
+               
+               verify(customBindingExampleService).requestResponse(request);
+       }
+
+}
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java b/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java
new file mode 100644 (file)
index 0000000..a6d493b
--- /dev/null
@@ -0,0 +1,34 @@
+package de.spring.webservices.services;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import de.spring.webservices.auto.CustomBindingExampleRequest;
+import de.spring.webservices.auto.CustomBindingExampleResponse;
+import de.spring.webservices.operations.Operations;
+import de.spring.webservices.services.impl.CustomBindingExampleServiceImpl;
+
+
+public class CustomBindingExampleServiceTest {
+
+       private Operations.RequestResponse
+       <CustomBindingExampleResponse, CustomBindingExampleRequest>  customBindingExampleService;
+       
+       @Before
+    public void init() {
+               customBindingExampleService = new CustomBindingExampleServiceImpl();
+       }
+       
+       @Test
+       public void givenCustomBindingExampleRequestThenReturnCustomBindingExampleResponse() {
+               CustomBindingExampleRequest request = new CustomBindingExampleRequest();
+               request.setData("SCARLETT");
+               CustomBindingExampleResponse expected = new CustomBindingExampleResponse();
+               expected.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData());
+               
+               CustomBindingExampleResponse actual = customBindingExampleService.requestResponse(request);
+        
+               Assert.assertEquals(expected.getData(), actual.getData());
+       }
+}
diff --git a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java b/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java
new file mode 100644 (file)
index 0000000..493c76d
--- /dev/null
@@ -0,0 +1,32 @@
+package de.spring.webservices.services;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import de.spring.webservices.auto.ExampleRequest;
+import de.spring.webservices.auto.ExampleResponse;
+import de.spring.webservices.services.impl.ExampleServiceImpl;
+
+public class ExampleServiceTest {
+
+    private ExampleService exampleService;
+       
+       @Before
+    public void init() {
+               exampleService = new ExampleServiceImpl();
+       }
+
+       @Test
+       public void givenExampleRequestThenReturnExampleResponse() {
+               ExampleRequest request = new ExampleRequest();
+               request.setData("SCARLETT");
+               ExampleResponse expected = new ExampleResponse();
+               expected.setData("SNAKE EYES AND " + request.getData());
+               
+        ExampleResponse actual = exampleService.doResponse(request);
+        
+               Assert.assertEquals(expected.getData(), actual.getData());
+       }
+
+}
diff --git a/jaxb2/web-services-spring-jaxb2/pom.xml b/jaxb2/web-services-spring-jaxb2/pom.xml
new file mode 100644 (file)
index 0000000..da59eba
--- /dev/null
@@ -0,0 +1,191 @@
+<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>
+       <groupId>de.spring.webservices</groupId>
+       <artifactId>web-services-spring-jaxb2</artifactId>
+       <packaging>pom</packaging>
+       <version>1.0-SNAPSHOT</version>
+       <name>web-services-spring-jaxb2</name>
+       <url>http://gumartinm.name</url>
+       <description>Web Services Spring Framework</description>
+       <organization>
+               <name>Gustavo Martin Morcuende</name>
+               <url>http://www.gumartinm.name</url>
+       </organization>
+       <scm>
+               <developerConnection>scm:git:http://git.gumartinm.name/SpringWebServicesForFun</developerConnection>
+               <url>http://git.gumartinm.name/SpringWebServicesForFun</url>
+       </scm>
+
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+               <!-- Be aware: spring-ws latest version does not follow spring-context 
+                       latest version -->
+               <spring.version>4.0.9.RELEASE</spring.version>
+               <spring.ws.version>2.2.1.RELEASE</spring.ws.version>
+       </properties>
+
+       <profiles>
+               <profile>
+                       <id>release</id>
+                       <properties>
+                               <environment.profile>release</environment.profile>
+                       </properties>
+                       <activation>
+                               <activeByDefault>true</activeByDefault>
+                       </activation>
+               </profile>
+       </profiles>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.apache.logging.log4j</groupId>
+                       <artifactId>log4j-slf4j-impl</artifactId>
+                       <version>2.3</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.logging.log4j</groupId>
+                       <artifactId>log4j-core</artifactId>
+                       <version>2.3</version>
+               </dependency>
+               <dependency>
+                       <groupId>cglib</groupId>
+                       <artifactId>cglib</artifactId>
+                       <version>2.2.2</version>
+               </dependency>
+       </dependencies>
+       <dependencyManagement>
+               <dependencies>
+                       <dependency>
+                               <groupId>org.springframework.ws</groupId>
+                               <artifactId>spring-ws-core</artifactId>
+                               <version>${spring.ws.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework.ws</groupId>
+                               <artifactId>spring-xml</artifactId>
+                               <version>${spring.ws.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.jdom</groupId>
+                               <artifactId>jdom</artifactId>
+                               <version>2.0.2</version>
+                       </dependency>
+
+                       <!-- Required by spring-ws-core -->
+                       <dependency>
+                               <groupId>wsdl4j</groupId>
+                               <artifactId>wsdl4j</artifactId>
+                               <version>1.6.3</version>
+                       </dependency>
+
+                       <!-- Unitary and integration tests -->
+                       <dependency>
+                               <groupId>junit</groupId>
+                               <artifactId>junit</artifactId>
+                               <version>4.12</version>
+                               <scope>test</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework</groupId>
+                               <artifactId>spring-test</artifactId>
+                               <version>${spring.version}</version>
+                               <scope>test</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.springframework.ws</groupId>
+                               <artifactId>spring-ws-test</artifactId>
+                               <version>${spring.ws.version}</version>
+                               <scope>test</scope>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.mockito</groupId>
+                               <artifactId>mockito-core</artifactId>
+                               <version>2.0.11-beta</version>
+                               <scope>test</scope>
+                       </dependency>
+               </dependencies>
+       </dependencyManagement>
+       <build>
+
+               <pluginManagement>
+                       <plugins>
+                               <plugin>
+                                       <groupId>org.apache.maven.plugins</groupId>
+                                       <artifactId>maven-surefire-plugin</artifactId>
+                                       <version>2.18.1</version>
+                               </plugin>
+                               <plugin>
+                                       <groupId>org.apache.maven.plugins</groupId>
+                                       <artifactId>maven-failsafe-plugin</artifactId>
+                                       <version>2.18.1</version>
+                               </plugin>
+                       </plugins>
+               </pluginManagement>
+
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>3.3</version>
+                               <configuration>
+                                       <source>1.8</source>
+                                       <target>1.8</target>
+                                       <encoding>${project.build.sourceEncoding}</encoding>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-resources-plugin</artifactId>
+                               <version>2.7</version>
+                               <configuration>
+                                       <encoding>${project.build.sourceEncoding}</encoding>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-jar-plugin</artifactId>
+                               <version>2.4</version>
+                               <configuration>
+                                       <archive>
+                                               <manifestEntries>
+                                                       <Specification-Title>${project.description}</Specification-Title>
+                                                       <Specification-Version>${project.version}</Specification-Version>
+                                                       <Specification-Vendor>${project.organization.name}</Specification-Vendor>
+                                                       <Implementation-Title>${project.description}</Implementation-Title>
+                                                       <Implementation-Version>${project.version}</Implementation-Version>
+                                                       <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
+                                               </manifestEntries>
+                                       </archive>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <configuration>
+                                       <excludes>
+                                               <exclude>**/*IntegrationTest.java</exclude>
+                                       </excludes>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-failsafe-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>integration-test</goal>
+                                                       <goal>verify</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                               <configuration>
+                                       <includes>
+                                               <include>**/*IntegrationTest.java</include>
+                                       </includes>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+</project>