From 82e90fdd60f30f0465ca96f22de229de0f323697 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Mon, 25 May 2015 05:19:48 +0200 Subject: [PATCH] Spring Web Services SOAP: new implementation --- README.md | 8 + pom.xml | 444 --------------------- .../webservices/business/BusinessExample.java | 23 -- .../business/CustomBindingBusinessExample.java | 24 -- .../spring/webservices/client/ExampleClient.java | 60 --- .../java/de/spring/webservices/client/Test.java | 27 -- .../webservices/endpoints/ExampleEndPoint.java | 58 --- .../spring/webservices/operations/Operations.java | 111 ------ .../de/spring/webservices/operations/Request.java | 5 - .../de/spring/webservices/operations/Response.java | 5 - src/main/resources/client-spring-configuration.xml | 60 --- src/main/resources/log4j.properties | 8 - src/main/resources/spring-configuration.xml | 97 ----- src/main/resources/wsdl/custombindingexample.wsdl | 116 ------ src/main/resources/xsd/custombinding.xjb | 42 -- src/main/resources/xsd/examples.xsd | 56 --- src/main/webapp/WEB-INF/spring-ws-servlet.xml | 9 - src/main/webapp/WEB-INF/web.xml | 25 -- .../tests/client/ExampleClientIntegrationTest.java | 48 --- .../server/ExampleEndPointIntegrationTest.java | 45 --- web-services-spring-client/pom.xml | 170 ++++++++ .../webservices/client/ExampleClientService.java | 69 ++++ .../de/spring/webservices/client/MainTest.java | 31 ++ .../spring/webservices/operations/Operations.java | 111 ++++++ .../de/spring/webservices/operations/Request.java | 5 + .../de/spring/webservices/operations/Response.java | 5 + .../src/main/resources/bindings/custombinding.xjb | 44 ++ .../client-spring-configuration.xml | 80 ++++ .../src/main/resources/wsdl/example.wsdl | 113 ++++++ .../src/main/resources/xsd/examples.xsd | 60 +++ .../ExampleClientServiceIntegrationTest.java | 59 +++ web-services-spring-server/pom.xml | 203 ++++++++++ .../business/CustomBindingBusinessExample.java | 25 ++ .../webservices/endpoints/ExampleEndPoint.java | 56 +++ .../spring/webservices/operations/Operations.java | 111 ++++++ .../de/spring/webservices/operations/Request.java | 5 + .../de/spring/webservices/operations/Response.java | 5 + .../src/main/jetty/jetty-http.xml | 71 ++++ .../src/main/resources/bindings/custombinding.xjb | 42 ++ .../src/main/resources/log4j2.xml | 14 + .../spring-configuration/spring-configuration.xml | 14 + .../resources/spring-configuration/ws/soap-ws.xml | 91 +++++ .../src/main/resources/xsd/examples.xsd | 60 +++ .../src/main/webapp/WEB-INF/web.xml | 44 ++ .../endpoints/ExampleEndPointIntegrationTest.java | 47 +++ web-services-spring/pom.xml | 142 +++++++ 46 files changed, 1685 insertions(+), 1263 deletions(-) delete mode 100644 pom.xml delete mode 100644 src/main/java/de/spring/webservices/business/BusinessExample.java delete mode 100644 src/main/java/de/spring/webservices/business/CustomBindingBusinessExample.java delete mode 100644 src/main/java/de/spring/webservices/client/ExampleClient.java delete mode 100644 src/main/java/de/spring/webservices/client/Test.java delete mode 100644 src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java delete mode 100644 src/main/java/de/spring/webservices/operations/Operations.java delete mode 100644 src/main/java/de/spring/webservices/operations/Request.java delete mode 100644 src/main/java/de/spring/webservices/operations/Response.java delete mode 100644 src/main/resources/client-spring-configuration.xml delete mode 100644 src/main/resources/log4j.properties delete mode 100644 src/main/resources/spring-configuration.xml delete mode 100644 src/main/resources/wsdl/custombindingexample.wsdl delete mode 100644 src/main/resources/xsd/custombinding.xjb delete mode 100644 src/main/resources/xsd/examples.xsd delete mode 100644 src/main/webapp/WEB-INF/spring-ws-servlet.xml delete mode 100644 src/main/webapp/WEB-INF/web.xml delete mode 100644 src/test/java/de/spring/webservices/tests/client/ExampleClientIntegrationTest.java delete mode 100644 src/test/java/de/spring/webservices/tests/server/ExampleEndPointIntegrationTest.java create mode 100644 web-services-spring-client/pom.xml create mode 100644 web-services-spring-client/src/main/java/de/spring/webservices/client/ExampleClientService.java create mode 100644 web-services-spring-client/src/main/java/de/spring/webservices/client/MainTest.java create mode 100644 web-services-spring-client/src/main/java/de/spring/webservices/operations/Operations.java create mode 100644 web-services-spring-client/src/main/java/de/spring/webservices/operations/Request.java create mode 100644 web-services-spring-client/src/main/java/de/spring/webservices/operations/Response.java create mode 100644 web-services-spring-client/src/main/resources/bindings/custombinding.xjb create mode 100644 web-services-spring-client/src/main/resources/spring-configuration/client-spring-configuration.xml create mode 100644 web-services-spring-client/src/main/resources/wsdl/example.wsdl create mode 100644 web-services-spring-client/src/main/resources/xsd/examples.xsd create mode 100644 web-services-spring-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java create mode 100644 web-services-spring-server/pom.xml create mode 100644 web-services-spring-server/src/main/java/de/spring/webservices/business/CustomBindingBusinessExample.java create mode 100644 web-services-spring-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java create mode 100644 web-services-spring-server/src/main/java/de/spring/webservices/operations/Operations.java create mode 100644 web-services-spring-server/src/main/java/de/spring/webservices/operations/Request.java create mode 100644 web-services-spring-server/src/main/java/de/spring/webservices/operations/Response.java create mode 100644 web-services-spring-server/src/main/jetty/jetty-http.xml create mode 100644 web-services-spring-server/src/main/resources/bindings/custombinding.xjb create mode 100644 web-services-spring-server/src/main/resources/log4j2.xml create mode 100644 web-services-spring-server/src/main/resources/spring-configuration/spring-configuration.xml create mode 100644 web-services-spring-server/src/main/resources/spring-configuration/ws/soap-ws.xml create mode 100644 web-services-spring-server/src/main/resources/xsd/examples.xsd create mode 100644 web-services-spring-server/src/main/webapp/WEB-INF/web.xml create mode 100644 web-services-spring-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java create mode 100644 web-services-spring/pom.xml diff --git a/README.md b/README.md index acf8a71..a9896b3 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,17 @@ SpringWebServicesForFun 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" diff --git a/pom.xml b/pom.xml deleted file mode 100644 index fc0e355..0000000 --- a/pom.xml +++ /dev/null @@ -1,444 +0,0 @@ - - - - 4.0.0 - de.spring.webservices - web-services-spring - 1 - web-services-spring - http://www.gumartinm.name - Web Services Spring Framework - - Gustavo Martin Inc. - http://www.gumartinm.name - - - - scm:git:http://git.gumartinm.name/SpringWebServicesForFun - http://git.gumartinm.name/SpringWebServicesForFun - - - - src/main/resources/xsd - ${basedir}/target/generated-sources/src/main/java - de.spring.webservices.auto - src/main/resources/wsdl - 2.2.1.RELEASE - UTF-8 - 4.1.6.RELEASE - ${basedir}/target/jetty - - - - - - org.springframework.ws - spring-ws-core - ${spring.ws.version} - - - org.springframework.ws - spring-xml - ${spring.ws.version} - - - org.springframework.ws - spring-ws-test - ${spring.ws.version} - test - - - org.springframework - spring-test - ${spring.version} - test - - - - - wsdl4j - wsdl4j - 1.6.3 - - - - org.jdom - jdom - 2.0.1 - - - com.sun.xml.ws - jaxws-rt - 2.2.5 - - - jaxen - jaxen - 1.1.3 - - - maven-cobertura-plugin - maven-plugins - - - maven-findbugs-plugin - maven-plugins - - - xml-apis - xml-apis - - - dom4j - dom4j - - - jdom - jdom - - - xom - xom - - - xmlParserAPIs - xerces - - - xercesImpl - xerces - - - - - org.mortbay.jetty - jsp-2.1 - 6.1.14 - - - org.mortbay.jetty - jsp-api-2.1 - 6.1.14 - - - javax.servlet - servlet-api - 2.5 - - - org.eclipse.jetty - jetty-continuation - 7.0.0.v20091005 - - - org.eclipse.jetty - jetty-http - 7.0.0.v20091005 - - - org.eclipse.jetty - jetty-io - 7.0.0.v20091005 - - - org.eclipse.jetty - jetty-security - 7.0.0.v20091005 - - - org.eclipse.jetty - jetty-server - 7.0.0.v20091005 - - - org.eclipse.jetty - jetty-servlet - 7.0.0.v20091005 - - - org.eclipse.jetty - jetty-webapp - 7.0.0.v20091005 - - - org.eclipse.jetty - jetty-util - 7.0.0.v20091005 - - - org.eclipse.jetty - jetty-xml - 7.0.0.v20091005 - - - junit - junit - 4.12 - test - - - - - org.jvnet.jaxb2_commons - jaxb2-basics-runtime - 0.9.4 - - - - - - - - org.apache.cxf - cxf-xjc-plugin - 3.0.3 - - - - org.apache.cxf - cxf-codegen-plugin - 3.1.0 - - - org.codehaus.mojo - build-helper-maven-plugin - 1.1 - - - org.mortbay.jetty - maven-jetty-plugin - 6.1.14 - - - org.apache.maven.plugins - maven-war-plugin - 2.1-alpha-2 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - ${project.build.sourceEncoding} - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.6 - - - org.codehaus.mojo - jdepend-maven-plugin - 2.0-beta-2 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.4.2 - - true - - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.1 - - - - ${project.description} - ${project.version} - ${project.organization.name} - ${project.description} - ${project.version} - ${project.organization.name} - - - - - - - - org.apache.cxf - cxf-xjc-plugin - - - org.apache.cxf.xjcplugins:cxf-xjc-dv:2.3.0 - - - - - generate-sources-from-xsd - generate-sources - - xsdtojava - - - ${project.xsd.schemas.target.path} - - - true - ${project.xsd.schemas.source.path}/examples.xsd - ${project.xsd.schemas.source.path}/custombinding.xjb - ${project.xsd.schemas.package.name} - - -Xinheritance - -Xannotate - - - - - - - - - - org.jvnet.jaxb2_commons - jaxb2-basics - 0.9.4 - - - - - org.jvnet.jaxb2_commons - jaxb2-basics-annotate - 1.0.1 - - - - - - - org.apache.cxf - cxf-codegen-plugin - - - generate-sources-from-wsdl - generate-sources - - wsdl2java - - - ${project.xsd.schemas.target.path} - - - - ${project.wsdl.sources.path}/custombindingexample.wsdl - - -xjc-Xinheritance - - - - - - - - - - org.jvnet.jaxb2_commons - jaxb2-basics - 0.9.4 - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.xsd.schemas.target.path} - - - - - - - org.mortbay.jetty - maven-jetty-plugin - - - / - - - ${basedir}/src/main/webapp, - ${warTarget} - - - - - - 8888 - 60000 - - - 3 - - ${warTarget} - - - - - org.apache.maven.plugins - maven-war-plugin - - ${basedir}/src/main/webapp - ${warTarget} - ${project.artifactId} - - - - - diff --git a/src/main/java/de/spring/webservices/business/BusinessExample.java b/src/main/java/de/spring/webservices/business/BusinessExample.java deleted file mode 100644 index 8a722b8..0000000 --- a/src/main/java/de/spring/webservices/business/BusinessExample.java +++ /dev/null @@ -1,23 +0,0 @@ -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 { - - @Override - public ExampleResponse requestResponse(final ExampleRequest request) { - final ExampleResponse response = new ObjectFactory().createExampleResponse(); - - response.setData("SNAKE EYES AND " + request.getData()); - - return response; - } - -} diff --git a/src/main/java/de/spring/webservices/business/CustomBindingBusinessExample.java b/src/main/java/de/spring/webservices/business/CustomBindingBusinessExample.java deleted file mode 100644 index 864afa9..0000000 --- a/src/main/java/de/spring/webservices/business/CustomBindingBusinessExample.java +++ /dev/null @@ -1,24 +0,0 @@ -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 { - - @Override - public CustomBindingExampleResponse requestResponse(final CustomBindingExampleRequest request) { - final CustomBindingExampleResponse response = new ObjectFactory().createCustomBindingExampleResponse(); - - response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); - - return response; - } - -} diff --git a/src/main/java/de/spring/webservices/client/ExampleClient.java b/src/main/java/de/spring/webservices/client/ExampleClient.java deleted file mode 100644 index 3512d28..0000000 --- a/src/main/java/de/spring/webservices/client/ExampleClient.java +++ /dev/null @@ -1,60 +0,0 @@ -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()); - } -} diff --git a/src/main/java/de/spring/webservices/client/Test.java b/src/main/java/de/spring/webservices/client/Test.java deleted file mode 100644 index 37f979c..0000000 --- a/src/main/java/de/spring/webservices/client/Test.java +++ /dev/null @@ -1,27 +0,0 @@ -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(); - } -} diff --git a/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java b/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java deleted file mode 100644 index cef1f83..0000000 --- a/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java +++ /dev/null @@ -1,58 +0,0 @@ -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 example; - private Operations.RequestResponse 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 example) { - this.example = example; - } - - public void setCustomBindingExample( - final Operations.RequestResponse customBindingExample) { - this.customBindingExample = customBindingExample; - } -} diff --git a/src/main/java/de/spring/webservices/operations/Operations.java b/src/main/java/de/spring/webservices/operations/Operations.java deleted file mode 100644 index 13b5113..0000000 --- a/src/main/java/de/spring/webservices/operations/Operations.java +++ /dev/null @@ -1,111 +0,0 @@ -package de.spring.webservices.operations; - -/** - *

- * Operations: WSDL v1.1 and v2.0 - *

- * See: http://www.w3.org/TR/wsdl#_porttypes
- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - */ -public interface Operations { - - /** - *

- * Request-response operation WSDL v1.1 - *

- * See: http://www.w3.org - * /TR/wsdl#_request-response - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public static interface RequestResponse { - T requestResponse(E request); - } - - /** - *

- * One-way operation WSDL v1.1 - *

- * See: http://www.w3.org/TR/wsdl - * #_one-way - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface OneWay { - void oneWay(E request); - } - - /** - *

- * Notification operation WSDL v1.1 - *

- * See: http://www.w3.org/TR - * /wsdl#_notification - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface Notification { - T notification(); - } - - /** - *

- * In-Only message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Request} - */ - public interface InOnly { - void inOnly(E request); - } - - /** - *

- * Robust In-Only message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Request} - */ - public interface RobustInOnly { - void robustInOnly(E request); - } - - /** - *

- * In-Out message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface InOut { - T inOut(E request); - } -} \ No newline at end of file diff --git a/src/main/java/de/spring/webservices/operations/Request.java b/src/main/java/de/spring/webservices/operations/Request.java deleted file mode 100644 index 77d81f4..0000000 --- a/src/main/java/de/spring/webservices/operations/Request.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.spring.webservices.operations; - -public interface Request { - -} diff --git a/src/main/java/de/spring/webservices/operations/Response.java b/src/main/java/de/spring/webservices/operations/Response.java deleted file mode 100644 index 3a2cbea..0000000 --- a/src/main/java/de/spring/webservices/operations/Response.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.spring.webservices.operations; - -public interface Response { - -} diff --git a/src/main/resources/client-spring-configuration.xml b/src/main/resources/client-spring-configuration.xml deleted file mode 100644 index 83c6910..0000000 --- a/src/main/resources/client-spring-configuration.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties deleted file mode 100644 index 999a154..0000000 --- a/src/main/resources/log4j.properties +++ /dev/null @@ -1,8 +0,0 @@ -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 diff --git a/src/main/resources/spring-configuration.xml b/src/main/resources/spring-configuration.xml deleted file mode 100644 index ec5aa9a..0000000 --- a/src/main/resources/spring-configuration.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.springframework.oxm.ValidationFailureException=CLIENT,Invalid request - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/wsdl/custombindingexample.wsdl b/src/main/resources/wsdl/custombindingexample.wsdl deleted file mode 100644 index 0f163b1..0000000 --- a/src/main/resources/wsdl/custombindingexample.wsdl +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/xsd/custombinding.xjb b/src/main/resources/xsd/custombinding.xjb deleted file mode 100644 index 08d81e9..0000000 --- a/src/main/resources/xsd/custombinding.xjb +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - de.spring.webservices.operations.Request - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - - - - - - - de.spring.webservices.operations.Response - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - - - - - - diff --git a/src/main/resources/xsd/examples.xsd b/src/main/resources/xsd/examples.xsd deleted file mode 100644 index f8f068b..0000000 --- a/src/main/resources/xsd/examples.xsd +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/webapp/WEB-INF/spring-ws-servlet.xml b/src/main/webapp/WEB-INF/spring-ws-servlet.xml deleted file mode 100644 index 88b4eb1..0000000 --- a/src/main/webapp/WEB-INF/spring-ws-servlet.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 2789794..0000000 --- a/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - Spring Web Services: example - - - spring-ws - org.springframework.ws.transport.http.MessageDispatcherServlet - 1 - - transformWsdlLocations - true - - - - - - spring-ws - /spring-ws/* - - - - diff --git a/src/test/java/de/spring/webservices/tests/client/ExampleClientIntegrationTest.java b/src/test/java/de/spring/webservices/tests/client/ExampleClientIntegrationTest.java deleted file mode 100644 index db51938..0000000 --- a/src/test/java/de/spring/webservices/tests/client/ExampleClientIntegrationTest.java +++ /dev/null @@ -1,48 +0,0 @@ -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( - "" - + "SCARLETT. IT IS CANON." - + ""); - final Source responsePayload = new StringSource( - "" - + "SNAKE EYES AND SCARLETT. IT IS CANON." - + ""); - mockServer.expect(payload(requestPayload)).andRespond( - withPayload(responsePayload)); - - mockServer.verify(); - } -} diff --git a/src/test/java/de/spring/webservices/tests/server/ExampleEndPointIntegrationTest.java b/src/test/java/de/spring/webservices/tests/server/ExampleEndPointIntegrationTest.java deleted file mode 100644 index ee41c24..0000000 --- a/src/test/java/de/spring/webservices/tests/server/ExampleEndPointIntegrationTest.java +++ /dev/null @@ -1,45 +0,0 @@ -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( - "" + - "SCARLETT" + - ""); - final Source responsePayload = new StringSource( - "" + - "SNAKE EYES AND SCARLETT" + - ""); - mockClient.sendRequest(withPayload(requestPayload)).andExpect( - payload(responsePayload)); - } -} diff --git a/web-services-spring-client/pom.xml b/web-services-spring-client/pom.xml new file mode 100644 index 0000000..4ba6e18 --- /dev/null +++ b/web-services-spring-client/pom.xml @@ -0,0 +1,170 @@ + + 4.0.0 + + web-services-spring + de.spring.webservices + 1.0-SNAPSHOT + + web-services-spring-client + web-services-spring-client + http://gumartinm.name + + + src/main/resources/wsdl + ${basedir}/target/generated-sources/src/main/java + src/main/resources/bindings + + + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + spring-xml + + + org.jdom + jdom + + + + + wsdl4j + wsdl4j + + + + + org.jvnet.jaxb2_commons + jaxb2-basics-runtime + 0.9.4 + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.springframework.ws + spring-ws-test + test + + + + + ${project.artifactId} + + + ${basedir}/src/main/resources/ + + **/*.* + + + + + + + org.apache.cxf + cxf-codegen-plugin + 3.1.0 + + + generate-sources-from-wsdl + generate-sources + + wsdl2java + + + ${project.wsdl.target.path} + + + + ${project.wsdl.sources.path}/example.wsdl + + ${project.bindings.path}/custombinding.xjb + + + -xjc-Xinheritance + -xjc-Xannotate + -verbose + + + + + + + + + + org.jvnet.jaxb2_commons + jaxb2-basics + 0.9.4 + + + + + org.jvnet.jaxb2_commons + jaxb2-basics-annotate + 1.0.1 + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + ${project.wsdl.target.path} + + + + + + + + + diff --git a/web-services-spring-client/src/main/java/de/spring/webservices/client/ExampleClientService.java b/web-services-spring-client/src/main/java/de/spring/webservices/client/ExampleClientService.java new file mode 100644 index 0000000..71d357b --- /dev/null +++ b/web-services-spring-client/src/main/java/de/spring/webservices/client/ExampleClientService.java @@ -0,0 +1,69 @@ +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; + } +} diff --git a/web-services-spring-client/src/main/java/de/spring/webservices/client/MainTest.java b/web-services-spring-client/src/main/java/de/spring/webservices/client/MainTest.java new file mode 100644 index 0000000..fc808e3 --- /dev/null +++ b/web-services-spring-client/src/main/java/de/spring/webservices/client/MainTest.java @@ -0,0 +1,31 @@ +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(); + } +} diff --git a/web-services-spring-client/src/main/java/de/spring/webservices/operations/Operations.java b/web-services-spring-client/src/main/java/de/spring/webservices/operations/Operations.java new file mode 100644 index 0000000..13b5113 --- /dev/null +++ b/web-services-spring-client/src/main/java/de/spring/webservices/operations/Operations.java @@ -0,0 +1,111 @@ +package de.spring.webservices.operations; + +/** + *

+ * Operations: WSDL v1.1 and v2.0 + *

+ * See: http://www.w3.org/TR/wsdl#_porttypes
+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + */ +public interface Operations { + + /** + *

+ * Request-response operation WSDL v1.1 + *

+ * See: http://www.w3.org + * /TR/wsdl#_request-response + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public static interface RequestResponse { + T requestResponse(E request); + } + + /** + *

+ * One-way operation WSDL v1.1 + *

+ * See: http://www.w3.org/TR/wsdl + * #_one-way + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface OneWay { + void oneWay(E request); + } + + /** + *

+ * Notification operation WSDL v1.1 + *

+ * See: http://www.w3.org/TR + * /wsdl#_notification + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface Notification { + T notification(); + } + + /** + *

+ * In-Only message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Request} + */ + public interface InOnly { + void inOnly(E request); + } + + /** + *

+ * Robust In-Only message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Request} + */ + public interface RobustInOnly { + void robustInOnly(E request); + } + + /** + *

+ * In-Out message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface InOut { + T inOut(E request); + } +} \ No newline at end of file diff --git a/web-services-spring-client/src/main/java/de/spring/webservices/operations/Request.java b/web-services-spring-client/src/main/java/de/spring/webservices/operations/Request.java new file mode 100644 index 0000000..77d81f4 --- /dev/null +++ b/web-services-spring-client/src/main/java/de/spring/webservices/operations/Request.java @@ -0,0 +1,5 @@ +package de.spring.webservices.operations; + +public interface Request { + +} diff --git a/web-services-spring-client/src/main/java/de/spring/webservices/operations/Response.java b/web-services-spring-client/src/main/java/de/spring/webservices/operations/Response.java new file mode 100644 index 0000000..3a2cbea --- /dev/null +++ b/web-services-spring-client/src/main/java/de/spring/webservices/operations/Response.java @@ -0,0 +1,5 @@ +package de.spring.webservices.operations; + +public interface Response { + +} diff --git a/web-services-spring-client/src/main/resources/bindings/custombinding.xjb b/web-services-spring-client/src/main/resources/bindings/custombinding.xjb new file mode 100644 index 0000000..4663aad --- /dev/null +++ b/web-services-spring-client/src/main/resources/bindings/custombinding.xjb @@ -0,0 +1,44 @@ + + + + + + + + + + + diff --git a/web-services-spring-client/src/main/resources/spring-configuration/client-spring-configuration.xml b/web-services-spring-client/src/main/resources/spring-configuration/client-spring-configuration.xml new file mode 100644 index 0000000..32da905 --- /dev/null +++ b/web-services-spring-client/src/main/resources/spring-configuration/client-spring-configuration.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web-services-spring-client/src/main/resources/wsdl/example.wsdl b/web-services-spring-client/src/main/resources/wsdl/example.wsdl new file mode 100644 index 0000000..895be2b --- /dev/null +++ b/web-services-spring-client/src/main/resources/wsdl/example.wsdl @@ -0,0 +1,113 @@ + + + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web-services-spring-client/src/main/resources/xsd/examples.xsd b/web-services-spring-client/src/main/resources/xsd/examples.xsd new file mode 100644 index 0000000..7f431c6 --- /dev/null +++ b/web-services-spring-client/src/main/resources/xsd/examples.xsd @@ -0,0 +1,60 @@ + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web-services-spring-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java b/web-services-spring-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java new file mode 100644 index 0000000..d4ebf5a --- /dev/null +++ b/web-services-spring-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java @@ -0,0 +1,59 @@ +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( + "" + + "SCARLETT SPRING. IT IS CANON." + + ""); + final Source responsePayload = new StringSource( + "" + + "SNAKE EYES AND SCARLETT SPRING. IT IS CANON." + + ""); + 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(); + } +} + diff --git a/web-services-spring-server/pom.xml b/web-services-spring-server/pom.xml new file mode 100644 index 0000000..18ec398 --- /dev/null +++ b/web-services-spring-server/pom.xml @@ -0,0 +1,203 @@ + + 4.0.0 + + web-services-spring + de.spring.webservices + 1.0-SNAPSHOT + + web-services-spring-server + war + web-services-spring-server + http://gumartinm.name + + + 9.3.0.RC0 + src/main/resources/xsd + ${basedir}/target/generated-sources/src/main/java + de.spring.webservices.auto + src/main/resources/bindings + + + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + spring-xml + + + org.jdom + jdom + + + + + wsdl4j + wsdl4j + + + + + org.jvnet.jaxb2_commons + jaxb2-basics-runtime + 0.9.4 + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.springframework.ws + spring-ws-test + test + + + + + ${project.artifactId} + + + ${basedir}/src/main/webapp + + **/*.* + + + + ${basedir}/src/main/resources/ + + **/*.* + + + + + + + org.apache.cxf + cxf-xjc-plugin + 3.0.3 + + + org.apache.cxf.xjcplugins:cxf-xjc-dv:2.3.0 + + + + + generate-sources-from-xsd + generate-sources + + xsdtojava + + + ${project.xsd.schemas.target.path} + + + true + ${project.xsd.schemas.source.path}/examples.xsd + ${project.bindings.path}/custombinding.xjb + ${project.xsd.schemas.package.name} + + -Xinheritance + -Xannotate + + + + + + + + + + org.jvnet.jaxb2_commons + jaxb2-basics + 0.9.4 + + + + + org.jvnet.jaxb2_commons + jaxb2-basics-annotate + 1.0.1 + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + ${project.xsd.schemas.target.path} + + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + + true + src/main/webapp + + WEB-INF/web.xml + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + ${basedir}/src/main/jetty/jetty-http.xml + + + + + diff --git a/web-services-spring-server/src/main/java/de/spring/webservices/business/CustomBindingBusinessExample.java b/web-services-spring-server/src/main/java/de/spring/webservices/business/CustomBindingBusinessExample.java new file mode 100644 index 0000000..3d5646e --- /dev/null +++ b/web-services-spring-server/src/main/java/de/spring/webservices/business/CustomBindingBusinessExample.java @@ -0,0 +1,25 @@ +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 { + + + @Override + public CustomBindingExampleResponse requestResponse( + final CustomBindingExampleRequest request) { + final CustomBindingExampleResponse response = new CustomBindingExampleResponse(); + + response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); + + return response; + } + +} diff --git a/web-services-spring-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java b/web-services-spring-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java new file mode 100644 index 0000000..6a91779 --- /dev/null +++ b/web-services-spring-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java @@ -0,0 +1,56 @@ +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 + customBindingExample; + + @Autowired + public ExampleEndPoint( + RequestResponse 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); + } +} + diff --git a/web-services-spring-server/src/main/java/de/spring/webservices/operations/Operations.java b/web-services-spring-server/src/main/java/de/spring/webservices/operations/Operations.java new file mode 100644 index 0000000..13b5113 --- /dev/null +++ b/web-services-spring-server/src/main/java/de/spring/webservices/operations/Operations.java @@ -0,0 +1,111 @@ +package de.spring.webservices.operations; + +/** + *

+ * Operations: WSDL v1.1 and v2.0 + *

+ * See: http://www.w3.org/TR/wsdl#_porttypes
+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + */ +public interface Operations { + + /** + *

+ * Request-response operation WSDL v1.1 + *

+ * See: http://www.w3.org + * /TR/wsdl#_request-response + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public static interface RequestResponse { + T requestResponse(E request); + } + + /** + *

+ * One-way operation WSDL v1.1 + *

+ * See: http://www.w3.org/TR/wsdl + * #_one-way + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface OneWay { + void oneWay(E request); + } + + /** + *

+ * Notification operation WSDL v1.1 + *

+ * See: http://www.w3.org/TR + * /wsdl#_notification + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface Notification { + T notification(); + } + + /** + *

+ * In-Only message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Request} + */ + public interface InOnly { + void inOnly(E request); + } + + /** + *

+ * Robust In-Only message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Request} + */ + public interface RobustInOnly { + void robustInOnly(E request); + } + + /** + *

+ * In-Out message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface InOut { + T inOut(E request); + } +} \ No newline at end of file diff --git a/web-services-spring-server/src/main/java/de/spring/webservices/operations/Request.java b/web-services-spring-server/src/main/java/de/spring/webservices/operations/Request.java new file mode 100644 index 0000000..77d81f4 --- /dev/null +++ b/web-services-spring-server/src/main/java/de/spring/webservices/operations/Request.java @@ -0,0 +1,5 @@ +package de.spring.webservices.operations; + +public interface Request { + +} diff --git a/web-services-spring-server/src/main/java/de/spring/webservices/operations/Response.java b/web-services-spring-server/src/main/java/de/spring/webservices/operations/Response.java new file mode 100644 index 0000000..3a2cbea --- /dev/null +++ b/web-services-spring-server/src/main/java/de/spring/webservices/operations/Response.java @@ -0,0 +1,5 @@ +package de.spring.webservices.operations; + +public interface Response { + +} diff --git a/web-services-spring-server/src/main/jetty/jetty-http.xml b/web-services-spring-server/src/main/jetty/jetty-http.xml new file mode 100644 index 0000000..d995630 --- /dev/null +++ b/web-services-spring-server/src/main/jetty/jetty-http.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + https + + + + 32768 + 8192 + 8192 + true + false + 512 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web-services-spring-server/src/main/resources/bindings/custombinding.xjb b/web-services-spring-server/src/main/resources/bindings/custombinding.xjb new file mode 100644 index 0000000..eea1cfe --- /dev/null +++ b/web-services-spring-server/src/main/resources/bindings/custombinding.xjb @@ -0,0 +1,42 @@ + + + + + + + + + de.spring.webservices.operations.Request + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + + + + + + + de.spring.webservices.operations.Response + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + + + + + + diff --git a/web-services-spring-server/src/main/resources/log4j2.xml b/web-services-spring-server/src/main/resources/log4j2.xml new file mode 100644 index 0000000..18a4008 --- /dev/null +++ b/web-services-spring-server/src/main/resources/log4j2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/web-services-spring-server/src/main/resources/spring-configuration/spring-configuration.xml b/web-services-spring-server/src/main/resources/spring-configuration/spring-configuration.xml new file mode 100644 index 0000000..7341c77 --- /dev/null +++ b/web-services-spring-server/src/main/resources/spring-configuration/spring-configuration.xml @@ -0,0 +1,14 @@ + + + + diff --git a/web-services-spring-server/src/main/resources/spring-configuration/ws/soap-ws.xml b/web-services-spring-server/src/main/resources/spring-configuration/ws/soap-ws.xml new file mode 100644 index 0000000..0f7854c --- /dev/null +++ b/web-services-spring-server/src/main/resources/spring-configuration/ws/soap-ws.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.springframework.oxm.ValidationFailureException=CLIENT,Invalid request + + + + + diff --git a/web-services-spring-server/src/main/resources/xsd/examples.xsd b/web-services-spring-server/src/main/resources/xsd/examples.xsd new file mode 100644 index 0000000..7f431c6 --- /dev/null +++ b/web-services-spring-server/src/main/resources/xsd/examples.xsd @@ -0,0 +1,60 @@ + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web-services-spring-server/src/main/webapp/WEB-INF/web.xml b/web-services-spring-server/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..7e14eba --- /dev/null +++ b/web-services-spring-server/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + + Spring Web Services: example + + + + org.springframework.web.context.ContextLoaderListener + + + + + spring.profiles.active + ${environment.profile} + contextConfigLocation + + classpath*:spring-configuration/*.xml + + + + + + spring-ws + org.springframework.ws.transport.http.MessageDispatcherServlet + 1 + true + + contextConfigLocation + classpath*:spring-configuration/ws/*.xml + + + transformWsdlLocations + true + + + + + spring-ws + /spring-ws/* + + + diff --git a/web-services-spring-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java b/web-services-spring-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java new file mode 100644 index 0000000..7832cb1 --- /dev/null +++ b/web-services-spring-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java @@ -0,0 +1,47 @@ +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( + "" + + "SCARLETT" + + ""); + final Source responsePayload = new StringSource( + "" + + "SNAKE EYES AND SCARLETT" + + ""); + mockClient.sendRequest(withPayload(requestPayload)).andExpect( + payload(responsePayload)); + } +} + diff --git a/web-services-spring/pom.xml b/web-services-spring/pom.xml new file mode 100644 index 0000000..c1085dd --- /dev/null +++ b/web-services-spring/pom.xml @@ -0,0 +1,142 @@ + + 4.0.0 + de.spring.webservices + web-services-spring + pom + 1.0-SNAPSHOT + web-services-spring + http://gumartinm.name + Web Services Spring Framework + + Gustavo Martin Morcuende + http://www.gumartinm.name + + + scm:git:http://git.gumartinm.name/SpringWebServicesForFun + http://git.gumartinm.name/SpringWebServicesForFun + + + + UTF-8 + + 4.0.9.RELEASE + 2.2.1.RELEASE + + + + + release + + release + + + true + + + + + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.3 + + + org.apache.logging.log4j + log4j-core + 2.3 + + + cglib + cglib + 2.2.2 + + + + + + org.springframework.ws + spring-ws-core + ${spring.ws.version} + + + org.springframework.ws + spring-xml + ${spring.ws.version} + + + org.jdom + jdom + 2.0.2 + + + + + wsdl4j + wsdl4j + 1.6.3 + + + + + junit + junit + 4.12 + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.springframework.ws + spring-ws-test + ${spring.ws.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + ${project.description} + ${project.version} + ${project.organization.name} + ${project.description} + ${project.version} + ${project.organization.name} + + + + + + + -- 2.1.4