From ccd7575b7d202f416cf2f1acc78197cbeaf2a267 Mon Sep 17 00:00:00 2001 From: gumartinm Date: Mon, 5 Nov 2012 00:43:12 +0100 Subject: [PATCH] Trying to implement web services with Spring. --- pom.xml | 256 +++++++++++++++++++++ .../de/spring/webservices/service/TestService.java | 13 ++ .../de/spring/webservices/ws/HolidayEndpoint.java | 46 ++++ src/main/webapp/WEB-INF/spring-ws-servlet.xml | 29 +++ src/main/webapp/WEB-INF/web.xml | 25 ++ src/main/webapp/WEB-INF/xsd/messages.xsd | 17 ++ 6 files changed, 386 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/de/spring/webservices/service/TestService.java create mode 100644 src/main/java/de/spring/webservices/ws/HolidayEndpoint.java create mode 100644 src/main/webapp/WEB-INF/spring-ws-servlet.xml create mode 100644 src/main/webapp/WEB-INF/web.xml create mode 100644 src/main/webapp/WEB-INF/xsd/messages.xsd diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b2b904f --- /dev/null +++ b/pom.xml @@ -0,0 +1,256 @@ + + + + 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 + + + + + gumartinm-releases + gumartinm-releases + http://gumartinm.name/artifactory + + + gumartinm-snapshots-releases + gumartinm-snapshots-releases + http://gumartinm.name/artifactory + + + gumartinm + file:///opt/javadoc + + + + + + scm:git:http://git.gumartinm.name/web-services-spring + http://git.gumartinm.name/web-services-spring + + + + + 2.1.0.RELEASE + UTF-8 + 3.1.1.RELEASE + + + + + org.springframework.ws + spring-ws-core + ${spring.ws.version} + + + org.springframework.ws + spring-xml + ${spring.ws.version} + + + 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.10 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + ${project.build.sourceEncoding} + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + ${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 + 2.3.0 + + + org.apache.cxf + cxf-codegen-plugin + 2.3.0 + + + org.codehaus.mojo + build-helper-maven-plugin + 1.1 + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + + + diff --git a/src/main/java/de/spring/webservices/service/TestService.java b/src/main/java/de/spring/webservices/service/TestService.java new file mode 100644 index 0000000..82db9be --- /dev/null +++ b/src/main/java/de/spring/webservices/service/TestService.java @@ -0,0 +1,13 @@ +package de.spring.webservices.service; + +public class TestService { + private String notification = "HOLA GUS"; + + public void setNotification(final String notification) { + this.notification = notification; + } + + public String getNotification() { + return this.notification; + } +} diff --git a/src/main/java/de/spring/webservices/ws/HolidayEndpoint.java b/src/main/java/de/spring/webservices/ws/HolidayEndpoint.java new file mode 100644 index 0000000..216f484 --- /dev/null +++ b/src/main/java/de/spring/webservices/ws/HolidayEndpoint.java @@ -0,0 +1,46 @@ +package de.spring.webservices.ws; + +import org.jdom2.Element; +import org.jdom2.JDOMException; +import org.jdom2.Namespace; +import org.jdom2.xpath.XPath; +import org.springframework.beans.factory.annotation.Autowired; +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.service.TestService; + + + +@Endpoint +public class HolidayEndpoint { + private static final String NAMESPACE_URI = "http://localhost:8080/spring-ws/orders"; + private final XPath notificationExpression; + private TestService testService = new TestService(); + + @Autowired + public HolidayEndpoint(final TestService testService) throws JDOMException { + this.testService = testService; + final Namespace namespace = Namespace.getNamespace("", NAMESPACE_URI); + notificationExpression = XPath.newInstance("//ord:GetOrdersRequest"); + notificationExpression.addNamespace(namespace); + } + + @PayloadRoot(localPart = "GetOrdersRequest", namespace = NAMESPACE_URI) + public void order(@RequestPayload final Element notificationRequest) throws Exception { + + final String notification = notificationExpression.valueOf(notificationRequest); + //humanResourceService.bookHoliday(startDate, endDate, name); + testService.setNotification(notification); + } + + + @PayloadRoot(localPart = "GetOrdersResponse", namespace = NAMESPACE_URI) + @ResponsePayload + public Element getOrder(@RequestPayload final Element element) { + return new Element("hola", Namespace.getNamespace("", NAMESPACE_URI)); + // testService.getNotification(); + } +} diff --git a/src/main/webapp/WEB-INF/spring-ws-servlet.xml b/src/main/webapp/WEB-INF/spring-ws-servlet.xml new file mode 100644 index 0000000..43e9e57 --- /dev/null +++ b/src/main/webapp/WEB-INF/spring-ws-servlet.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..f455591 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,25 @@ + + + + Archetype Created Web Application + + + spring-ws + org.springframework.ws.transport.http.MessageDispatcherServlet + 1 + + transformWsdlLocations + true + + + + + + spring-ws + /* + + + + diff --git a/src/main/webapp/WEB-INF/xsd/messages.xsd b/src/main/webapp/WEB-INF/xsd/messages.xsd new file mode 100644 index 0000000..33b9613 --- /dev/null +++ b/src/main/webapp/WEB-INF/xsd/messages.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + -- 2.1.4