Messing around with Spring Web Services
mvn clean install
+mvn clean install && mvn dependency:sources && mvn dependency:resolve -Dclassifier=javadoc
mvn war:war
mvn jetty:run
+mvn clean install -Dmaven.test.skip=true
+
TODO: custom bindings when creating Java code from wsdl.
+TODO: using Jetty instead of Tomcat
+TODO: logging Spring information
+TODO: test catalog.cat support for Apache CXF (searching in classpath) See: http://labs.bsb.com/2011/01/usage-of-an-xml-catalog-in-the-xmlbeans-cxf-integration/
+and http://cxf.apache.org/cxf-xjc-plugin.html
+TODO: integration tests (client and server)
For debugging: export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<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</artifactId>
- <version>1</version>
- <name>web-services-spring</name>
- <url>http://www.gumartinm.name</url>
- <description>Web Services Spring Framework</description>
- <organization>
- <name>Gustavo Martin Inc.</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.xsd.schemas.source.path>src/main/resources/xsd</project.xsd.schemas.source.path>
- <project.xsd.schemas.target.path>${basedir}/target/generated-sources/src/main/java</project.xsd.schemas.target.path>
- <project.xsd.schemas.package.name>de.spring.webservices.auto</project.xsd.schemas.package.name>
- <project.wsdl.sources.path>src/main/resources/wsdl</project.wsdl.sources.path>
- <spring.ws.version>2.2.1.RELEASE</spring.ws.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <spring.version>4.1.6.RELEASE</spring.version>
- <warTarget>${basedir}/target/jetty</warTarget>
- </properties>
-
-
- <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.springframework.ws</groupId>
- <artifactId>spring-ws-test</artifactId>
- <version>${spring.ws.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring.version}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Required by spring-ws-core -->
- <dependency>
- <groupId>wsdl4j</groupId>
- <artifactId>wsdl4j</artifactId>
- <version>1.6.3</version>
- </dependency>
-
- <dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.ws</groupId>
- <artifactId>jaxws-rt</artifactId>
- <version>2.2.5</version>
- </dependency>
- <dependency>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
- <version>1.1.3</version>
- <exclusions>
- <exclusion>
- <artifactId>maven-cobertura-plugin</artifactId>
- <groupId>maven-plugins</groupId>
- </exclusion>
- <exclusion>
- <artifactId>maven-findbugs-plugin</artifactId>
- <groupId>maven-plugins</groupId>
- </exclusion>
- <exclusion>
- <artifactId>xml-apis</artifactId>
- <groupId>xml-apis</groupId>
- </exclusion>
- <exclusion>
- <artifactId>dom4j</artifactId>
- <groupId>dom4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>jdom</artifactId>
- <groupId>jdom</groupId>
- </exclusion>
- <exclusion>
- <artifactId>xom</artifactId>
- <groupId>xom</groupId>
- </exclusion>
- <exclusion>
- <artifactId>xmlParserAPIs</artifactId>
- <groupId>xerces</groupId>
- </exclusion>
- <exclusion>
- <artifactId>xercesImpl</artifactId>
- <groupId>xerces</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jsp-2.1</artifactId>
- <version>6.1.14</version>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jsp-api-2.1</artifactId>
- <version>6.1.14</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-continuation</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-http</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-io</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-security</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlet</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-xml</artifactId>
- <version>7.0.0.v20091005</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </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>
- </dependencies>
- <build>
- <pluginManagement>
- <plugins>
- <!-- Generate code from xsd files -->
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-xjc-plugin</artifactId>
- <version>3.0.3</version>
- </plugin>
- <!-- Generate code from wsdl files (the client's code) -->
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-codegen-plugin</artifactId>
- <version>3.1.0</version>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.1</version>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.14</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.1-alpha-2</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-javadoc-plugin</artifactId>
- <version>2.6</version>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jdepend-maven-plugin</artifactId>
- <version>2.0-beta-2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.2</version>
- <configuration>
- <testFailureIgnore>true</testFailureIgnore>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.3.1</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>
-
- <!-- We could use maven-jaxb2-plugin in order to generate Java classes from XSD files but
- this plugin seems more useful so, I keep using it. Besides, it is based on Apache CXF which
- as well, uses jaxb. -->
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-xjc-plugin</artifactId>
- <configuration>
- <extensions>
- <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.3.0</extension>
- </extensions>
- </configuration>
- <executions>
- <execution>
- <id>generate-sources-from-xsd</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>xsdtojava</goal>
- </goals>
- <configuration>
- <sourceRoot>${project.xsd.schemas.target.path}</sourceRoot>
- <xsdOptions>
- <xsdOption>
- <extension>true</extension>
- <xsd>${project.xsd.schemas.source.path}/examples.xsd</xsd>
- <bindingFile>${project.xsd.schemas.source.path}/custombinding.xjb</bindingFile>
- <packagename>${project.xsd.schemas.package.name}</packagename>
- <extensionArgs>
- <extraarg>-Xinheritance</extraarg>
- <extraarg>-Xannotate</extraarg>
- </extensionArgs>
- </xsdOption>
- </xsdOptions>
- </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 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 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>
-
- <!-- 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. -->
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-codegen-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-sources-from-wsdl</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>wsdl2java</goal>
- </goals>
- <configuration>
- <sourceRoot>${project.xsd.schemas.target.path}</sourceRoot>
- <wsdlOptions>
- <wsdlOption>
- <!--
- <wsdl>${project.wsdl.sources.path}/example.wsdl</wsdl>
- -->
- <wsdl>${project.wsdl.sources.path}/custombindingexample.wsdl</wsdl>
- <extraargs>
- <extraarg>-xjc-Xinheritance</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 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>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${project.xsd.schemas.target.path}</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <configuration>
- <webAppConfig>
- <contextPath>/</contextPath>
- <baseResource implementation="org.mortbay.resource.ResourceCollection">
- <resourcesAsCSV>
- ${basedir}/src/main/webapp,
- ${warTarget}
- </resourcesAsCSV>
- </baseResource>
- </webAppConfig>
- <connectors>
- <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
- <port>8888</port>
- <maxIdleTime>60000</maxIdleTime>
- </connector>
- </connectors>
- <scanIntervalSeconds>3</scanIntervalSeconds>
- <scanTargets>
- <scanTarget>${warTarget}</scanTarget>
- </scanTargets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
- <webappDirectory>${warTarget}</webappDirectory>
- <warName>${project.artifactId}</warName>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-package de.spring.webservices.business;
-
-import de.spring.webservices.auto.ExampleRequest;
-import de.spring.webservices.auto.ExampleResponse;
-import de.spring.webservices.auto.ObjectFactory;
-import de.spring.webservices.operations.Operations;
-
-/**
- * Example of business class
- *
- */
-public class BusinessExample implements Operations.RequestResponse<ExampleResponse, ExampleRequest> {
-
- @Override
- public ExampleResponse requestResponse(final ExampleRequest request) {
- final ExampleResponse response = new ObjectFactory().createExampleResponse();
-
- response.setData("SNAKE EYES AND " + request.getData());
-
- return response;
- }
-
-}
+++ /dev/null
-package de.spring.webservices.business;
-
-import de.spring.webservices.auto.CustomBindingExampleRequest;
-import de.spring.webservices.auto.CustomBindingExampleResponse;
-import de.spring.webservices.auto.ObjectFactory;
-import de.spring.webservices.operations.Operations;
-
-/**
- * Example of business class
- *
- */
-public class CustomBindingBusinessExample
- implements Operations.RequestResponse<CustomBindingExampleResponse, CustomBindingExampleRequest> {
-
- @Override
- public CustomBindingExampleResponse requestResponse(final CustomBindingExampleRequest request) {
- final CustomBindingExampleResponse response = new ObjectFactory().createCustomBindingExampleResponse();
-
- response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData());
-
- return response;
- }
-
-}
+++ /dev/null
-package de.spring.webservices.client;
-
-import localhost._8888.spring_ws.example.CustomBindingExampleRequest;
-import localhost._8888.spring_ws.example.CustomBindingExampleResponse;
-import localhost._8888.spring_ws.example.ExampleRequest;
-import localhost._8888.spring_ws.example.ExampleResponse;
-import localhost._8888.spring_ws.example.Examples;
-import localhost._8888.spring_ws.example.ExamplesService;
-import localhost._8888.spring_ws.example.ObjectFactory;
-
-import org.springframework.ws.client.core.WebServiceTemplate;
-
-/**
- * Someone could write code like this one in order to send and receive
- * information from our Web Services.
- *
- */
-public class ExampleClient {
- private WebServiceTemplate webServiceTemplate;
- private String Uri;
-
-
- public void setWebServiceTemplate(
- final WebServiceTemplate webServiceTemplate) {
- this.webServiceTemplate = webServiceTemplate;
- }
-
- public void setDefaultUri(final String defaultUri) {
- this.Uri = defaultUri;
- }
-
- public void sendAndReceive() {
- final Examples exampleService = new ExamplesService().getExamplesSoap11();
- final ExampleRequest exampleRequest = new ObjectFactory().createExampleRequest();
- final CustomBindingExampleRequest customBindingxampleRequest =
- new ObjectFactory().createCustomBindingExampleRequest();
- exampleRequest.setData("SCARLETT. IT IS CANON.");
- customBindingxampleRequest.setData("CUSTOM BINDING. SCARLETT. IT IS CANON.");
-
- //There are two options O.o:
-
- //1. Through Java:
- ExampleResponse exampleResponse = exampleService.example(exampleRequest);
- System.out.println(exampleResponse.getData());
- CustomBindingExampleResponse customBindingExampleResponse =
- exampleService.customBindingExample(customBindingxampleRequest);
- System.out.println(customBindingExampleResponse.getData());
-
- //2. Using Spring:
- this.webServiceTemplate.setDefaultUri(this.Uri);
- exampleResponse = (ExampleResponse)
- this.webServiceTemplate.marshalSendAndReceive(exampleRequest);
- this.webServiceTemplate.setDefaultUri(this.Uri);
- customBindingExampleResponse = (CustomBindingExampleResponse) this.webServiceTemplate
- .marshalSendAndReceive(customBindingxampleRequest);
-
- System.out.println(exampleResponse.getData());
- System.out.println(customBindingExampleResponse.getData());
- }
-}
+++ /dev/null
-package de.spring.webservices.client;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * 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 Test {
- public ApplicationContext context;
-
- /**
- * @param args
- */
- public static void main(final String[] args) {
- final Test test = new Test();
-
- test.context = new ClassPathXmlApplicationContext(
- "client-spring-configuration.xml");
-
- final ExampleClient example = (ExampleClient) test.context.getBean("exampleClient");
-
- example.sendAndReceive();
- }
-}
+++ /dev/null
-package de.spring.webservices.endpoints;
-
-import org.jdom2.Element;
-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;
-
-
-@Endpoint
-public class ExampleEndPoint {
- private static final String NAMESPACE_URI = "http://localhost:8888/spring-ws/example";
- private Operations.RequestResponse<ExampleResponse, ExampleRequest> example;
- private Operations.RequestResponse<CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExample;
-
-
- public ExampleEndPoint() {}
-
-
- @PayloadRoot(localPart = "ExampleRequest", namespace = NAMESPACE_URI)
- @ResponsePayload
- public ExampleResponse order(
- @RequestPayload final ExampleRequest requestObject,
- @RequestPayload final Element element,
- final MessageContext messageContext) {
-
- return example.requestResponse(requestObject);
- }
-
- @PayloadRoot(localPart = "CustomBindingExampleRequest", namespace = NAMESPACE_URI)
- @ResponsePayload
- public CustomBindingExampleResponse order(
- @RequestPayload final CustomBindingExampleRequest requestObject,
- @RequestPayload final Element element,
- final MessageContext messageContext) {
-
- return this.customBindingExample.requestResponse(requestObject);
- }
-
-
- /** Setter required by Spring **/
- public void setExample(
- final Operations.RequestResponse<ExampleResponse, ExampleRequest> example) {
- this.example = example;
- }
-
- public void setCustomBindingExample(
- final Operations.RequestResponse<CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExample) {
- this.customBindingExample = customBindingExample;
- }
-}
+++ /dev/null
-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
+++ /dev/null
-package de.spring.webservices.operations;
-
-public interface Request {
-
-}
+++ /dev/null
-package de.spring.webservices.operations;
-
-public interface Response {
-
-}
+++ /dev/null
-<?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"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/web-services
- http://www.springframework.org/schema/web-services/web-services-2.0.xsd
- http://www.springframework.org/schema/oxm
- http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd">
-
- <!--
- This file is an example about how someone should write code in order to send and
- receive data from the Web Services.
- -->
-
- <context:component-scan base-package="de.spring.webservices"/>
-
- <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
-
-
- <oxm:jaxb2-marshaller id="marshaller" contextPath="localhost._8888.spring_ws.example"/>
-
- <!-- ¿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)
- El marshal lo estoy haciendo con JAXB2 (lo que no sé es que JAXB2 está realmente usando
- pues me parece que hay varios en el classpath) y funciona, así que supongo que el
- validador también :/
- 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="schema" value="classpath:xsd/examples.xsd"/>
- <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" />
- <property name="defaultUri" value="http://localhost:8888/spring-ws/example"/>
- <property name="interceptors">
- <list>
- <ref bean="payloadValidatingInterceptor" />
- </list>
- </property>
- </bean>
-
- <bean id="exampleClient" class="de.spring.webservices.client.ExampleClient">
- <property name="webServiceTemplate" ref="webServiceTemplate"/>
- <property name="defaultUri" value="http://localhost:8888/spring-ws/example"/>
- </bean>
-
-</beans>
+++ /dev/null
-log4j.rootLogger=WARN, stdout
-log4j.logger.org.springframework.ws=INFO
-log4j.logger.org.springframework.xml=INFO
-log4j.logger.de.spring.webservices=INFO
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyyMMddHHmmssSSS} - %-5p - [%t] - %m%n
+++ /dev/null
-<?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">
-
-
- <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, creo que Spring lo que está haciendo es el equivalente ha si se
- escribiera lo siguiente:
-
- <oxm:jaxb2-marshaller id="marshaller" contextPath="de.spring.webservices.auto"/>
-
- <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://127.0.0.1:8888/spring-ws/example/example.wsdl
- -->
- <sws:dynamic-wsdl id="example" portTypeName="Examples"
- createSoap12Binding="true" createSoap11Binding="false"
- locationUri="/spring-ws/example">
- <sws:xsd location="classpath:xsd/examples.xsd"/>
- </sws:dynamic-wsdl>
-
-
- <!-- Required in order to use SOAP 1.2 -->
- <bean id="messageFactorySoap12" 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="schema" value="classpath:xsd/examples.xsd"/>
- <property name="validateRequest" value="false"/>
- <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>
-
- <bean id="exampleBusiness" class="de.spring.webservices.business.BusinessExample">
- </bean>
-
- <bean id="customBindingExampleBusiness" class="de.spring.webservices.business.CustomBindingBusinessExample">
- </bean>
-
- <bean id="exampleEndPoint" class="de.spring.webservices.endpoints.ExampleEndPoint" >
- <property name="example" ref="exampleBusiness" />
- <property name="customBindingExample" ref="customBindingExampleBusiness" />
- </bean>
-
-
-</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://localhost:8888/spring-ws/example" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8888/spring-ws/example" targetNamespace="http://localhost:8888/spring-ws/example">
- <wsdl:types>
- <xs:schema xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" jaxb:extensionBindingPrefixes="inheritance" jaxb:version="2.1" targetNamespace="http://localhost:8888/spring-ws/example">
-
-
- <xs:element name="ExampleRequest">
- <xs:complexType>
- <xs:annotation>
- <xs:appinfo>
- <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>
-
- <xs:element name="CustomBindingExampleRequest">
- <xs:complexType>
- <xs:annotation>
- <xs:appinfo>
- <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="CustomBindingExampleResponse">
- <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>
-
-
-</xs:schema>
- </wsdl:types>
- <wsdl:message name="CustomBindingExampleResponse">
- <wsdl:part element="tns:CustomBindingExampleResponse" name="CustomBindingExampleResponse">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="CustomBindingExampleRequest">
- <wsdl:part element="tns:CustomBindingExampleRequest" name="CustomBindingExampleRequest">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="ExampleRequest">
- <wsdl:part element="tns:ExampleRequest" name="ExampleRequest">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="ExampleResponse">
- <wsdl:part element="tns:ExampleResponse" name="ExampleResponse">
- </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="ExamplesSoap11" type="tns:Examples">
- <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
- <wsdl:operation name="CustomBindingExample">
- <soap:operation soapAction=""/>
- <wsdl:input name="CustomBindingExampleRequest">
- <soap:body use="literal"/>
- </wsdl:input>
- <wsdl:output name="CustomBindingExampleResponse">
- <soap:body use="literal"/>
- </wsdl:output>
- </wsdl:operation>
- <wsdl:operation name="Example">
- <soap:operation soapAction=""/>
- <wsdl:input name="ExampleRequest">
- <soap:body use="literal"/>
- </wsdl:input>
- <wsdl:output name="ExampleResponse">
- <soap:body use="literal"/>
- </wsdl:output>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:service name="ExamplesService">
- <wsdl:port binding="tns:ExamplesSoap11" name="ExamplesSoap11">
- <soap:address location="http://127.0.0.1:8888/spring-ws/example"/>
- </wsdl:port>
- </wsdl:service>
-</wsdl:definitions>
\ No newline at end of file
+++ /dev/null
-<?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"
- jaxb:version="2.1"
- jaxb:extensionBindingPrefixes="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="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="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 cand
- modify instead this file with your custom binding :) -->
-
-</jaxb:bindings>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-
-
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
- xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
- xmlns:annox="http://annox.dev.java.net"
- jaxb:version="2.1"
- jaxb:extensionBindingPrefixes="inheritance annox"
- elementFormDefault="qualified"
- targetNamespace="http://localhost:8888/spring-ws/example">
-
-
- <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>
-
- <xs:element name="CustomBindingExampleRequest">
- <xs:complexType>
- <xs:all>
- <xs:element name="data" type="xs:string" />
- </xs:all>
- </xs:complexType>
- </xs:element>
- <xs:element name="CustomBindingExampleResponse">
- <xs:complexType>
- <xs:all>
- <xs:element name="data" type="xs:string" />
- </xs:all>
- </xs:complexType>
- </xs:element>
-
-
-</xs:schema>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-
- <import resource="classpath:spring-configuration.xml"/>
-
-</beans>
+++ /dev/null
-<?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>
-
- <servlet>
- <servlet-name>spring-ws</servlet-name>
- <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- <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>
+++ /dev/null
-package de.spring.webservices.tests.client;
-
-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.test.client.MockWebServiceServer;
-import org.springframework.xml.transform.StringSource;
-
-import de.spring.webservices.client.ExampleClient;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("/client-spring-configuration.xml")
-public class ExampleClientIntegrationTest {
-
- @Autowired
- private ExampleClient client;
-
- private MockWebServiceServer mockServer;
-
- @Before
- public void createServer() throws Exception {
- // mockServer = MockWebServiceServer.createServer(client);
- }
-
- @Test
- public void customerClient() throws Exception {
- final Source requestPayload = new StringSource(
- "<ExampleRequest xmlns='http://localhost:8888/spring-ws/example'>"
- + "<data>SCARLETT. IT IS CANON.</data>"
- + "</ExampleRequest>");
- final Source responsePayload = new StringSource(
- "<ns2:ExampleResponse xmlns:ns2='http://localhost:8888/spring-ws/example'>"
- + "<ns2:data>SNAKE EYES AND SCARLETT. IT IS CANON.</ns2:data>"
- + "</ns2:ExampleResponse>");
- mockServer.expect(payload(requestPayload)).andRespond(
- withPayload(responsePayload));
-
- mockServer.verify();
- }
-}
+++ /dev/null
-package de.spring.webservices.tests.server;
-
-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("/spring-configuration.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://localhost:8888/spring-ws/example'>" +
- "<data>SCARLETT</data>" +
- "</ExampleRequest>");
- final Source responsePayload = new StringSource(
- "<ns2:ExampleResponse xmlns:ns2='http://localhost:8888/spring-ws/example'>" +
- "<ns2:data>SNAKE EYES AND SCARLETT</ns2:data>" +
- "</ns2:ExampleResponse>");
- mockClient.sendRequest(withPayload(requestPayload)).andExpect(
- payload(responsePayload));
- }
-}
--- /dev/null
+<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</artifactId>
+ <groupId>de.spring.webservices</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>web-services-spring-client</artifactId>
+ <name>web-services-spring-client</name>
+ <url>http://gumartinm.name</url>
+
+ <properties>
+ <project.wsdl.sources.path>src/main/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/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>
+
+ <!-- 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>
+ <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>-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>
+
--- /dev/null
+package de.spring.webservices.client;
+
+import name.gumartinm.spring_ws.example.CustomBindingExampleRequest;
+import name.gumartinm.spring_ws.example.CustomBindingExampleResponse;
+import name.gumartinm.spring_ws.example.ExampleRequest;
+import name.gumartinm.spring_ws.example.ExampleResponse;
+import name.gumartinm.spring_ws.example.Examples;
+import name.gumartinm.spring_ws.example.ExamplesService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ws.client.core.WebServiceTemplate;
+
+/**
+ * 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.");
+
+ 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;
+ }
+}
--- /dev/null
+package de.spring.webservices.client;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * 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 {
+ public ApplicationContext context;
+
+ /**
+ * @param args
+ */
+ public static void main(final String[] args) {
+ final MainTest test = new MainTest();
+
+ test.context = new ClassPathXmlApplicationContext(
+ "client-spring-configuration.xml");
+
+ final ExampleClientService example =
+ (ExampleClientService) test.context.getBean("exampleClient");
+
+ example.sendAndReceiveJava();
+ example.sendAndReceiveJavaCustom();
+ example.sendAndReceiveSpring();
+ example.sendAndReceiveSpringCustom();
+ }
+}
--- /dev/null
+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
--- /dev/null
+package de.spring.webservices.operations;
+
+public interface Request {
+
+}
--- /dev/null
+package de.spring.webservices.operations;
+
+public interface Response {
+
+}
--- /dev/null
+<?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"
+ jaxb:version="2.1"
+ jaxb:extensionBindingPrefixes="inheritance annox">
+
+ <!--
+ Se procesa con Xpath si quieres meter expresiones regulares y cosas así en teoría dependes de Xpath
+ por ejemplo esto: @name=match[.] se supone que debería funcionar pero me dice que no puede
+ cambiar mas de un nodo a la vez. Puede que sea un bug de xjc que se carga las opciones de Xpath :/
+ <jaxb:bindings schemaLocation="examples.xsd">
+ <jaxb:bindings node="//xsd:element[@name='ExampleRequest']/xsd:complexType">
+ <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+ </jaxb:bindings>
+ <jaxb:bindings node="//xsd:element[@name='ExampleResponse']/xsd:complexType">
+ <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+ </jaxb:bindings>
+ </jaxb:bindings>
+ -->
+
+ <!--
+ <jaxb:bindings schemaLocation="../xsd/examples.xsd">
+ <jaxb:bindings node="//xsd:element[@name='CustomBindingExampleRequest']/xsd:complexType">
+ <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+ <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
+ </jaxb:bindings>
+ </jaxb:bindings>
+
+
+ <jaxb:bindings schemaLocation="../xsd/examples.xsd">
+ <jaxb:bindings node="//xsd:element[@name='CustomBindingExampleResponse']/xsd:complexType">
+ <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+ <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
+ </jaxb:bindings>
+ </jaxb:bindings>
+ -->
+
+ <!-- The same applies to annotate. If you do not want or you may not modify your xsd files you can
+ modify instead this file with your custom binding :) -->
+
+</jaxb:bindings>
--- /dev/null
+<?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"
+ 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">
+
+ <!--
+ 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="name.gumartinm.spring_ws.example"/>
+
+ <!-- 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>
+
+ <!--
+ ¿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="schema" value="classpath:xsd/examples.xsd"/>
+ <property name="validateRequest" value="true"/>
+ <property name="validateResponse" value="true"/>
+ </bean>
+ </sws:interceptors>
+
+ <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
+ <constructor-arg ref="messageFactory"/>
+ <property name="marshaller" ref="marshaller" />
+ <property name="unmarshaller" ref="marshaller" />
+ <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.ExampleClient">
+ <property name="webServiceTemplate" ref="webServiceTemplate"/>
+ </bean>
+
+</beans>
--- /dev/null
+<?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/spring-ws/example" targetNamespace="http://gumartinm.name/spring-ws/example">
+ <wsdl:types>
+ <xs:schema xmlns:annox="http://annox.dev.java.net" xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 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">
+
+
+ <!-- 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:all>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CustomBindingExampleResponse">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="data" type="xs:string"/>
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+
+</xs:schema>
+ </wsdl:types>
+ <wsdl:message name="CustomBindingExampleRequest">
+ <wsdl:part element="tns:CustomBindingExampleRequest" name="CustomBindingExampleRequest">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="CustomBindingExampleResponse">
+ <wsdl:part element="tns:CustomBindingExampleResponse" name="CustomBindingExampleResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="ExampleRequest">
+ <wsdl:part element="tns:ExampleRequest" name="ExampleRequest">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="ExampleResponse">
+ <wsdl:part element="tns:ExampleResponse" name="ExampleResponse">
+ </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>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
+ xmlns:annox="http://annox.dev.java.net"
+ jaxb:version="2.1"
+ jaxb:extensionBindingPrefixes="inheritance annox"
+ elementFormDefault="qualified"
+ targetNamespace="http://gumartinm.name/spring-ws/example">
+
+
+ <!-- Using inheritance and annox plugin -->
+ <xs:element name="ExampleRequest">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
+ <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:all>
+ <xs:element name="data" type="xs:string" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="ExampleResponse">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:all>
+ <xs:element name="data" type="xs:string" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+
+ <!-- Using custombinding.xjb instead of inheritance plugin.
+ Useful when you can not modify your xsd files because they are provided
+ by another person or company
+ -->
+ <xs:element name="CustomBindingExampleRequest">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="data" type="xs:string" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CustomBindingExampleResponse">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="data" type="xs:string" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+
+</xs:schema>
--- /dev/null
+package de.spring.webservices.client;
+
+import static org.springframework.ws.test.client.RequestMatchers.payload;
+import static org.springframework.ws.test.client.ResponseCreators.withPayload;
+import static org.junit.Assert.*;
+
+import javax.xml.transform.Source;
+
+import name.gumartinm.spring_ws.example.ExampleResponse;
+
+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;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/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 exampleResponse = exampleClientService.sendAndReceiveSpring();
+
+ assertEquals(exampleResponse.getData(), "SNAKE EYES AND SCARLETT SPRING. IT IS CANON.");
+
+ mockServer.verify();
+ }
+}
+
--- /dev/null
+<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</artifactId>
+ <groupId>de.spring.webservices</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>web-services-spring-server</artifactId>
+ <packaging>war</packaging>
+ <name>web-services-spring-server</name>
+ <url>http://gumartinm.name</url>
+
+ <properties>
+ <jetty.version>9.3.0.RC0</jetty.version>
+ <project.xsd.schemas.source.path>src/main/resources/xsd</project.xsd.schemas.source.path>
+ <project.xsd.schemas.target.path>${basedir}/target/generated-sources/src/main/java</project.xsd.schemas.target.path>
+ <project.xsd.schemas.package.name>de.spring.webservices.auto</project.xsd.schemas.package.name>
+ <project.bindings.path>src/main/resources/bindings</project.bindings.path>
+ </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>
+
+ <!-- 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/webapp</directory>
+ <excludes>
+ <exclude>**/*.*</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>${basedir}/src/main/resources/</directory>
+ <includes>
+ <include>**/*.*</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <!-- Generate code from xsd files:
+ We could use maven-jaxb2-plugin in order to generate Java classes from XSD 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/cxf-xjc-plugin.html
+ -->
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-xjc-plugin</artifactId>
+ <version>3.0.3</version>
+ <configuration>
+ <extensions>
+ <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.3.0</extension>
+ </extensions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-sources-from-xsd</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>xsdtojava</goal>
+ </goals>
+ <configuration>
+ <sourceRoot>${project.xsd.schemas.target.path}</sourceRoot>
+ <xsdOptions>
+ <xsdOption>
+ <extension>true</extension>
+ <xsd>${project.xsd.schemas.source.path}/examples.xsd</xsd>
+ <bindingFile>${project.bindings.path}/custombinding.xjb</bindingFile>
+ <packagename>${project.xsd.schemas.package.name}</packagename>
+ <extensionArgs>
+ <extraarg>-Xinheritance</extraarg>
+ <extraarg>-Xannotate</extraarg>
+ </extensionArgs>
+ </xsdOption>
+ </xsdOptions>
+ </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 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 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.xsd.schemas.target.path}</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </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>
--- /dev/null
+package de.spring.webservices.business;
+
+import org.springframework.stereotype.Service;
+
+import de.spring.webservices.auto.CustomBindingExampleRequest;
+import de.spring.webservices.auto.CustomBindingExampleResponse;
+import de.spring.webservices.operations.Operations;
+
+
+@Service("customBindingBusinessExample")
+public class CustomBindingBusinessExample implements
+ Operations.RequestResponse<CustomBindingExampleResponse, CustomBindingExampleRequest> {
+
+
+ @Override
+ public CustomBindingExampleResponse requestResponse(
+ final CustomBindingExampleRequest request) {
+ final CustomBindingExampleResponse response = new CustomBindingExampleResponse();
+
+ response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData());
+
+ return response;
+ }
+
+}
--- /dev/null
+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;
+
+
+@Endpoint
+public class ExampleEndPoint {
+ private static final String NAMESPACE_URI = "http://gumartinm.name/spring-ws/example";
+
+ private final Operations.RequestResponse
+ <CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExample;
+
+ @Autowired
+ public ExampleEndPoint(
+ RequestResponse<CustomBindingExampleResponse, CustomBindingExampleRequest> customBindingExample) {
+ this.customBindingExample = customBindingExample;
+ }
+
+ @PayloadRoot(localPart = "ExampleRequest", namespace = NAMESPACE_URI)
+ @ResponsePayload
+ public ExampleResponse order(
+ @RequestPayload final ExampleRequest requestObject,
+ @RequestPayload final Element element,
+ final MessageContext messageContext) {
+
+ final ExampleResponse response = new ExampleResponse();
+
+ response.setData("SNAKE EYES AND " + requestObject.getData());
+
+ return response;
+ }
+
+ @PayloadRoot(localPart = "CustomBindingExampleRequest", namespace = NAMESPACE_URI)
+ @ResponsePayload
+ public CustomBindingExampleResponse order(
+ @RequestPayload final CustomBindingExampleRequest requestObject,
+ @RequestPayload final Element element,
+ final MessageContext messageContext) {
+
+ return this.customBindingExample.requestResponse(requestObject);
+ }
+}
+
--- /dev/null
+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
--- /dev/null
+package de.spring.webservices.operations;
+
+public interface Request {
+
+}
--- /dev/null
+package de.spring.webservices.operations;
+
+public interface Response {
+
+}
--- /dev/null
+<?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>
--- /dev/null
+<?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"
+ jaxb:version="2.1"
+ jaxb:extensionBindingPrefixes="inheritance annox">
+
+ <!--
+ Se procesa con Xpath si quieres meter expresiones regulares y cosas así en teoría dependes de Xpath
+ por ejemplo esto: @name=match[.] se supone que debería funcionar pero me dice que no puede
+ cambiar mas de un nodo a la vez. Puede que sea un bug de xjc que se carga las opciones de Xpath :/
+ <jaxb:bindings schemaLocation="examples.xsd">
+ <jaxb:bindings node="//xsd:element[@name='ExampleRequest']/xsd:complexType">
+ <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+ </jaxb:bindings>
+ <jaxb:bindings node="//xsd:element[@name='ExampleResponse']/xsd:complexType">
+ <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+ </jaxb:bindings>
+ </jaxb:bindings>
+ -->
+
+ <jaxb:bindings schemaLocation="../xsd/examples.xsd">
+ <jaxb:bindings node="//xsd:element[@name='CustomBindingExampleRequest']/xsd:complexType">
+ <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+ <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
+ </jaxb:bindings>
+ </jaxb:bindings>
+
+
+ <jaxb:bindings schemaLocation="../xsd/examples.xsd">
+ <jaxb:bindings node="//xsd:element[@name='CustomBindingExampleResponse']/xsd:complexType">
+ <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+ <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
+ </jaxb:bindings>
+ </jaxb:bindings>
+
+ <!-- The same applies to annotate. If you do not want or you may not modify your xsd files you can
+ modify instead this file with your custom binding :) -->
+
+</jaxb:bindings>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+<?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/spring-ws/example">
+ <sws:xsd location="classpath:xsd/examples.xsd"/>
+ </sws:dynamic-wsdl>
+
+
+ <!-- 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="schema" value="classpath:xsd/examples.xsd"/>
+ <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>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
+ xmlns:annox="http://annox.dev.java.net"
+ jaxb:version="2.1"
+ jaxb:extensionBindingPrefixes="inheritance annox"
+ elementFormDefault="qualified"
+ targetNamespace="http://gumartinm.name/spring-ws/example">
+
+
+ <!-- Using inheritance and annox plugin -->
+ <xs:element name="ExampleRequest">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <annox:annotate>@java.lang.SuppressWarnings({"unchecked","rawtypes"})</annox:annotate>
+ <inheritance:implements>de.spring.webservices.operations.Request</inheritance:implements>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:all>
+ <xs:element name="data" type="xs:string" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="ExampleResponse">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <inheritance:implements>de.spring.webservices.operations.Response</inheritance:implements>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:all>
+ <xs:element name="data" type="xs:string" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+
+ <!-- Using custombinding.xjb instead of inheritance plugin.
+ Useful when you can not modify your xsd files because they are provided
+ by another person or company
+ -->
+ <xs:element name="CustomBindingExampleRequest">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="data" type="xs:string" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CustomBindingExampleResponse">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="data" type="xs:string" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+
+</xs:schema>
--- /dev/null
+<?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>
--- /dev/null
+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("/spring-configuration.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));
+ }
+}
+
--- /dev/null
+<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</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>web-services-spring</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>
+ <!-- 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>
+ </dependencies>
+ </dependencyManagement>
+ <build>
+ <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>
+ </plugins>
+ </build>
+</project>