From e2a449da9766d3c6cec20c4c222d338ce1e06938 Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Fri, 28 Feb 2014 11:50:45 +0100 Subject: [PATCH 1/4] Spring Web Services Starter and Sample Project Fixes gh-412 --- spring-boot-dependencies/pom.xml | 107 +++++++++++++++--- spring-boot-samples/pom.xml | 3 +- .../spring-boot-sample-ws/README.md | 14 +++ .../spring-boot-sample-ws/pom.xml | 49 ++++++++ .../java/sample/ws/SampleWsApplication.java | 41 +++++++ .../sample/ws/endpoint/HolidayEndpoint.java | 58 ++++++++++ .../ws/service/HumanResourceService.java | 10 ++ .../ws/service/StubHumanResourceService.java | 21 ++++ .../main/resources/META-INF/schemas/hr.xsd | 26 +++++ .../META-INF/spring/spring-ws-context.xml | 13 +++ spring-boot-starters/pom.xml | 1 + .../spring-boot-starter-ws/pom.xml | 48 ++++++++ .../main/resources/META-INF/spring.provides | 1 + 13 files changed, 376 insertions(+), 16 deletions(-) create mode 100644 spring-boot-samples/spring-boot-sample-ws/README.md create mode 100644 spring-boot-samples/spring-boot-sample-ws/pom.xml create mode 100644 spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java create mode 100644 spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java create mode 100644 spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java create mode 100644 spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java create mode 100644 spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/schemas/hr.xsd create mode 100644 spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/spring/spring-ws-context.xml create mode 100644 spring-boot-starters/spring-boot-starter-ws/pom.xml create mode 100644 spring-boot-starters/spring-boot-starter-ws/src/main/resources/META-INF/spring.provides diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 798126d63f5..49e3d1f4c7a 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -79,6 +79,8 @@ 2.4.1 8.1.15.v20140411 2.2.0.v201112011158 + 1.1.6 + 2.0.1 2.3 1.2.1 1.2 @@ -109,6 +111,7 @@ 1.0.1.RELEASE 3.2.4.RELEASE 1.0.2.RELEASE + 2.1.4.RELEASE 2.1.3.RELEASE 2.1.1.RELEASE 1.2.4 @@ -330,6 +333,11 @@ spring-boot-starter-websocket 1.1.0.BUILD-SNAPSHOT + + org.springframework.boot + spring-boot-starter-ws + 1.1.0.BUILD-SNAPSHOT + @@ -454,6 +462,11 @@ jstl ${jstl.version} + + jaxen + jaxen + ${jaxen.version} + joda-time joda-time @@ -819,6 +832,11 @@ jolokia-core ${jolokia.version} + + org.jdom + jdom + ${jdom.version} + org.liquibase liquibase-core @@ -1049,39 +1067,98 @@ ${spring-social.version} - org.springframework.social - spring-social-facebook - ${spring-social-facebook.version} + org.springframework.mobile + spring-mobile-device + ${spring-mobile.version} - org.springframework.social - spring-social-facebook-web - ${spring-social-facebook.version} + org.springframework.ws + spring-ws-core + ${spring-ws.version} + + + commons-logging + commons-logging + + - org.springframework.social - spring-social-twitter - ${spring-social-twitter.version} + org.springframework.ws + spring-ws-support + ${spring-ws.version} + + + commons-logging + commons-logging + + - org.springframework.social - spring-social-linkedin - ${spring-social-linkedin.version} + org.springframework.ws + spring-ws-security + ${spring-ws.version} + + + commons-logging + commons-logging + + + + + org.springframework.ws + spring-ws-test + ${spring-ws.version} + + + commons-logging + commons-logging + + + + + wsdl4j + wsdl4j + 1.6.3 + + + xmlunit + xmlunit + 1.5 org.thymeleaf thymeleaf ${thymeleaf.version} + + org.thymeleaf + thymeleaf-spring4 + ${thymeleaf.version} + org.thymeleaf.extras thymeleaf-extras-springsecurity3 ${thymeleaf-extras-springsecurity3.version} - org.thymeleaf - thymeleaf-spring4 - ${thymeleaf.version} + org.springframework.social + spring-social-facebook + ${spring-social-facebook.version} + + + org.springframework.social + spring-social-facebook-web + ${spring-social-facebook.version} + + + org.springframework.social + spring-social-twitter + ${spring-social-twitter.version} + + + org.springframework.social + spring-social-linkedin + ${spring-social-linkedin.version} org.yaml diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index 18e2cc5135d..bb1a34e969d 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -57,7 +57,8 @@ spring-boot-sample-web-velocity spring-boot-sample-websocket spring-boot-sample-xml - + spring-boot-sample-ws + diff --git a/spring-boot-samples/spring-boot-sample-ws/README.md b/spring-boot-samples/spring-boot-sample-ws/README.md new file mode 100644 index 00000000000..40e58611053 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/README.md @@ -0,0 +1,14 @@ +# Spring Boot - Samples - Web Services + +This sample project demonstrates how to bootstrap and use Spring Web Services with Spring Boot. + +It is a runnable implementation of the HolidayRequest sample in the Spring Web Services [reference guide](http://docs.spring.io/spring-ws/site/reference/html/tutorial.html#tutorial.implementing.endpoint). + +The sample can be build with Maven (>3) and simply run from the command line. + +``` +$ mvn package +$ java -jar target/*.jar +``` + +Now pointing your browser to [http://localhost:8080/services/holidayService/holiday.wsdl] should display the generated WSDL. \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-ws/pom.xml b/spring-boot-samples/spring-boot-sample-ws/pom.xml new file mode 100644 index 00000000000..2549d930820 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/pom.xml @@ -0,0 +1,49 @@ + + + + spring-boot-samples + org.springframework.boot + 1.1.0.BUILD-SNAPSHOT + + 4.0.0 + + spring-boot-sample-ws + + + ${basedir}/../.. + 1.7 + + + + org.springframework.boot + spring-boot-starter-ws + + + org.springframework.boot + spring-boot-starter-actuator + + + org.jdom + jdom + + + jaxen + jaxen + + + ${project.groupId} + spring-boot-starter-test + test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java new file mode 100644 index 00000000000..2129f862dde --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java @@ -0,0 +1,41 @@ +package sample.ws; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.context.embedded.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.ws.transport.http.MessageDispatcherServlet; + +/** + * Created by in329dei on 28-2-14. + */ +@Configuration +@EnableAutoConfiguration +@ComponentScan +@ImportResource("classpath:/META-INF/spring/spring-ws-context.xml") +public class SampleWsApplication { + + public static void main(String[] args) throws Exception { + SpringApplication.run(SampleWsApplication.class, args); + } + + @Bean + public ServletRegistrationBean messageDispatcherServletRegistration() { + MessageDispatcherServlet mds = new MessageDispatcherServlet(); + mds.setTransformWsdlLocations(true); + + ServletRegistrationBean srb = new ServletRegistrationBean(messageDispatcherServlet(), "/services/*"); + srb.setLoadOnStartup(1); + return srb; + } + + @Bean + public MessageDispatcherServlet messageDispatcherServlet() { + MessageDispatcherServlet mds = new MessageDispatcherServlet(); + mds.setTransformWsdlLocations(true); + return mds; + } +} diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java new file mode 100644 index 00000000000..e6b9ed094b2 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java @@ -0,0 +1,58 @@ +package sample.ws.endpoint; + +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 sample.ws.service.HumanResourceService; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Created by in329dei on 28-2-14. + */ +@Endpoint +public class HolidayEndpoint { + + private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas"; + + private XPath startDateExpression; + + private XPath endDateExpression; + + private XPath nameExpression; + + private HumanResourceService humanResourceService; + + @Autowired + public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException + { + this.humanResourceService = humanResourceService; + + Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI); + + startDateExpression = XPath.newInstance("//hr:StartDate"); + startDateExpression.addNamespace(namespace); + + endDateExpression = XPath.newInstance("//hr:EndDate"); + endDateExpression.addNamespace(namespace); + + nameExpression = XPath.newInstance("concat(//hr:FirstName,' ',//hr:LastName)"); + nameExpression.addNamespace(namespace); + } + + @PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest") + public void handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date startDate = dateFormat.parse(startDateExpression.valueOf(holidayRequest)); + Date endDate = dateFormat.parse(endDateExpression.valueOf(holidayRequest)); + String name = nameExpression.valueOf(holidayRequest); + + humanResourceService.bookHoliday(startDate, endDate, name); + } +} diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java new file mode 100644 index 00000000000..6bcb287dfae --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java @@ -0,0 +1,10 @@ +package sample.ws.service; + +import java.util.Date; + +/** + * Created by in329dei on 28-2-14. + */ +public interface HumanResourceService { + void bookHoliday(Date startDate, Date endDate, String name); +} diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java new file mode 100644 index 00000000000..08118be6d94 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java @@ -0,0 +1,21 @@ +package sample.ws.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.util.Date; + +/** + * Created by in329dei on 28-2-14. + */ +@Service +public class StubHumanResourceService implements HumanResourceService { + + private final Logger logger = LoggerFactory.getLogger(StubHumanResourceService.class); + + @Override + public void bookHoliday(Date startDate, Date endDate, String name) { + logger.info("Booking holiday for [{} - {}] for [{}] ", startDate, endDate, name); + } +} diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/schemas/hr.xsd b/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/schemas/hr.xsd new file mode 100644 index 00000000000..eed94778e2e --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/schemas/hr.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/spring/spring-ws-context.xml b/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/spring/spring-ws-context.xml new file mode 100644 index 00000000000..d5022a615d1 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/spring/spring-ws-context.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-starters/pom.xml b/spring-boot-starters/pom.xml index 87c07167df7..d33244f4646 100644 --- a/spring-boot-starters/pom.xml +++ b/spring-boot-starters/pom.xml @@ -54,6 +54,7 @@ spring-boot-starter-velocity spring-boot-starter-web spring-boot-starter-websocket + spring-boot-starter-ws diff --git a/spring-boot-starters/spring-boot-starter-ws/pom.xml b/spring-boot-starters/spring-boot-starter-ws/pom.xml new file mode 100644 index 00000000000..348fc12f777 --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-ws/pom.xml @@ -0,0 +1,48 @@ + + + + spring-boot-starters + org.springframework.boot + 1.1.0.BUILD-SNAPSHOT + + 4.0.0 + + spring-boot-starter-ws + jar + + ${basedir}/../.. + + + + ${project.groupId} + spring-boot-starter + ${project.version} + + + ${project.groupId} + spring-boot-starter-tomcat + ${project.version} + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + spring-ws-support + + + org.springframework.ws + spring-ws-security + true + + + org.springframework.ws + spring-ws-test + test + + + + \ No newline at end of file diff --git a/spring-boot-starters/spring-boot-starter-ws/src/main/resources/META-INF/spring.provides b/spring-boot-starters/spring-boot-starter-ws/src/main/resources/META-INF/spring.provides new file mode 100644 index 00000000000..9a488a0a6dc --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-ws/src/main/resources/META-INF/spring.provides @@ -0,0 +1 @@ +provides: spring-ws-core,spring-ws-support,spring-ws-security \ No newline at end of file From 95a6ce9e48fc92f0d0839fbcd93d386bc0fb315e Mon Sep 17 00:00:00 2001 From: Maciej Walkowiak Date: Fri, 6 Jun 2014 15:37:30 +0200 Subject: [PATCH 2/4] Spring Web Services Starter - upgraded Spring WS to 2.2.0.RELEASE - replaced default MVC DispatcherServlet with MessageDispatcherServlet - migrated XML based config with nww Spring WS Java config Fixes: gh-412 --- pom.xml | 31 ++++--- spring-boot-dependencies/pom.xml | 7 +- .../spring-boot-sample-ws/pom.xml | 92 ++++++++++--------- .../java/sample/ws/SampleWsApplication.java | 28 +----- .../main/java/sample/ws/WebServiceConfig.java | 45 +++++++++ .../sample/ws/endpoint/HolidayEndpoint.java | 59 ++++++------ .../ws/service/HumanResourceService.java | 2 +- .../ws/service/StubHumanResourceService.java | 11 +-- .../META-INF/spring/spring-ws-context.xml | 13 --- .../spring-boot-starter-ws/pom.xml | 86 ++++++++--------- 10 files changed, 191 insertions(+), 183 deletions(-) create mode 100644 spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java delete mode 100644 spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/spring/spring-ws-context.xml diff --git a/pom.xml b/pom.xml index 37652568938..2c6def53f8c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.springframework.boot spring-boot-build @@ -148,20 +149,20 @@ false - - - - - - - + + + + + + + - + - + - + @@ -176,7 +177,7 @@ false - + - - - + + + diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 49e3d1f4c7a..8fe4b56bb91 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -111,7 +111,7 @@ 1.0.1.RELEASE 3.2.4.RELEASE 1.0.2.RELEASE - 2.1.4.RELEASE + 2.2.0.RELEASE 2.1.3.RELEASE 2.1.1.RELEASE 1.2.4 @@ -1066,11 +1066,6 @@ spring-social-web ${spring-social.version} - - org.springframework.mobile - spring-mobile-device - ${spring-mobile.version} - org.springframework.ws spring-ws-core diff --git a/spring-boot-samples/spring-boot-sample-ws/pom.xml b/spring-boot-samples/spring-boot-sample-ws/pom.xml index 2549d930820..2e6ef4e07c1 100644 --- a/spring-boot-samples/spring-boot-sample-ws/pom.xml +++ b/spring-boot-samples/spring-boot-sample-ws/pom.xml @@ -1,49 +1,53 @@ - - spring-boot-samples - org.springframework.boot - 1.1.0.BUILD-SNAPSHOT - - 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/xsd/maven-4.0.0.xsd"> + + spring-boot-samples + org.springframework.boot + 1.1.0.BUILD-SNAPSHOT + + 4.0.0 - spring-boot-sample-ws + spring-boot-sample-ws - - ${basedir}/../.. - 1.7 - - - - org.springframework.boot - spring-boot-starter-ws - - - org.springframework.boot - spring-boot-starter-actuator - - - org.jdom - jdom - - - jaxen - jaxen - - - ${project.groupId} - spring-boot-starter-test - test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + ${basedir}/../.. + 1.7 + + + + org.springframework.boot + spring-boot-starter-ws + + + org.springframework.boot + spring-boot-starter-actuator + + + org.jdom + jdom + + + jaxen + jaxen + + + wsdl4j + wsdl4j + + + ${project.groupId} + spring-boot-starter-test + test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java index 2129f862dde..5dd802eaf1d 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java @@ -2,12 +2,8 @@ package sample.ws; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.embedded.ServletRegistrationBean; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; -import org.springframework.ws.transport.http.MessageDispatcherServlet; /** * Created by in329dei on 28-2-14. @@ -15,27 +11,9 @@ import org.springframework.ws.transport.http.MessageDispatcherServlet; @Configuration @EnableAutoConfiguration @ComponentScan -@ImportResource("classpath:/META-INF/spring/spring-ws-context.xml") public class SampleWsApplication { - public static void main(String[] args) throws Exception { - SpringApplication.run(SampleWsApplication.class, args); - } - - @Bean - public ServletRegistrationBean messageDispatcherServletRegistration() { - MessageDispatcherServlet mds = new MessageDispatcherServlet(); - mds.setTransformWsdlLocations(true); - - ServletRegistrationBean srb = new ServletRegistrationBean(messageDispatcherServlet(), "/services/*"); - srb.setLoadOnStartup(1); - return srb; - } - - @Bean - public MessageDispatcherServlet messageDispatcherServlet() { - MessageDispatcherServlet mds = new MessageDispatcherServlet(); - mds.setTransformWsdlLocations(true); - return mds; - } + public static void main(String[] args) throws Exception { + SpringApplication.run(SampleWsApplication.class, args); + } } diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java new file mode 100644 index 00000000000..9935f7537b5 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java @@ -0,0 +1,45 @@ +package sample.ws; + +import org.springframework.boot.context.embedded.ServletRegistrationBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.ws.config.annotation.EnableWs; +import org.springframework.ws.config.annotation.WsConfigurerAdapter; +import org.springframework.ws.transport.http.MessageDispatcherServlet; +import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; +import org.springframework.xml.xsd.SimpleXsdSchema; +import org.springframework.xml.xsd.XsdSchema; + +/** + * Configures Spring Web Service components + * + * @author Maciej Walkowiak + */ +@EnableWs +@Configuration +public class WebServiceConfig extends WsConfigurerAdapter { + @Bean + public ServletRegistrationBean dispatcherServlet(ApplicationContext applicationContext) { + MessageDispatcherServlet servlet = new MessageDispatcherServlet(); + servlet.setApplicationContext(applicationContext); + + return new ServletRegistrationBean(servlet, "/services/*"); + } + + @Bean(name = "holiday") + public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) { + DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); + wsdl11Definition.setPortTypeName("HumanResource"); + wsdl11Definition.setLocationUri("/holidayService/"); + wsdl11Definition.setTargetNamespace("http://mycompany.com/hr/definitions"); + wsdl11Definition.setSchema(countriesSchema); + return wsdl11Definition; + } + + @Bean + public XsdSchema countriesSchema() { + return new SimpleXsdSchema(new ClassPathResource("META-INF/schemas/hr.xsd")); + } +} diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java index e6b9ed094b2..606367974fa 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java @@ -3,56 +3,55 @@ package sample.ws.endpoint; import org.jdom2.Element; import org.jdom2.JDOMException; import org.jdom2.Namespace; -import org.jdom2.xpath.XPath; +import org.jdom2.filter.Filters; +import org.jdom2.xpath.XPathExpression; +import org.jdom2.xpath.XPathFactory; 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 sample.ws.service.HumanResourceService; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactoryConfigurationException; import java.text.SimpleDateFormat; import java.util.Date; /** - * Created by in329dei on 28-2-14. + * @author in329dei + * @author Maciej Walkowiak */ @Endpoint public class HolidayEndpoint { - private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas"; + private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas"; - private XPath startDateExpression; + private XPathExpression startDateExpression; + private XPathExpression endDateExpression; + private XPathExpression nameExpression; - private XPath endDateExpression; + private HumanResourceService humanResourceService; - private XPath nameExpression; + @Autowired + public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException, XPathFactoryConfigurationException, XPathExpressionException { + this.humanResourceService = humanResourceService; - private HumanResourceService humanResourceService; + Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI); - @Autowired - public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException - { - this.humanResourceService = humanResourceService; + XPathFactory xPathFactory = XPathFactory.instance(); - Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI); + startDateExpression = xPathFactory.compile("//hr:StartDate", Filters.element(), null, namespace); + endDateExpression = xPathFactory.compile("//hr:EndDate", Filters.element(), null, namespace); + nameExpression = xPathFactory.compile("concat(//hr:FirstName,' ',//hr:LastName)", Filters.fstring(), null, namespace); + } - startDateExpression = XPath.newInstance("//hr:StartDate"); - startDateExpression.addNamespace(namespace); + @PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest") + public void handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date startDate = dateFormat.parse(startDateExpression.evaluateFirst(holidayRequest).getText()); + Date endDate = dateFormat.parse(endDateExpression.evaluateFirst(holidayRequest).getText()); + String name = nameExpression.evaluateFirst(holidayRequest); - endDateExpression = XPath.newInstance("//hr:EndDate"); - endDateExpression.addNamespace(namespace); - - nameExpression = XPath.newInstance("concat(//hr:FirstName,' ',//hr:LastName)"); - nameExpression.addNamespace(namespace); - } - - @PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest") - public void handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date startDate = dateFormat.parse(startDateExpression.valueOf(holidayRequest)); - Date endDate = dateFormat.parse(endDateExpression.valueOf(holidayRequest)); - String name = nameExpression.valueOf(holidayRequest); - - humanResourceService.bookHoliday(startDate, endDate, name); - } + humanResourceService.bookHoliday(startDate, endDate, name); + } } diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java index 6bcb287dfae..5f7c7416099 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java @@ -6,5 +6,5 @@ import java.util.Date; * Created by in329dei on 28-2-14. */ public interface HumanResourceService { - void bookHoliday(Date startDate, Date endDate, String name); + void bookHoliday(Date startDate, Date endDate, String name); } diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java index 08118be6d94..0f030889cf6 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java @@ -11,11 +11,10 @@ import java.util.Date; */ @Service public class StubHumanResourceService implements HumanResourceService { + private final Logger logger = LoggerFactory.getLogger(StubHumanResourceService.class); - private final Logger logger = LoggerFactory.getLogger(StubHumanResourceService.class); - - @Override - public void bookHoliday(Date startDate, Date endDate, String name) { - logger.info("Booking holiday for [{} - {}] for [{}] ", startDate, endDate, name); - } + @Override + public void bookHoliday(Date startDate, Date endDate, String name) { + logger.info("Booking holiday for [{} - {}] for [{}] ", startDate, endDate, name); + } } diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/spring/spring-ws-context.xml b/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/spring/spring-ws-context.xml deleted file mode 100644 index d5022a615d1..00000000000 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/spring/spring-ws-context.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/spring-boot-starters/spring-boot-starter-ws/pom.xml b/spring-boot-starters/spring-boot-starter-ws/pom.xml index 348fc12f777..5c3600a5b87 100644 --- a/spring-boot-starters/spring-boot-starter-ws/pom.xml +++ b/spring-boot-starters/spring-boot-starter-ws/pom.xml @@ -1,48 +1,48 @@ - - spring-boot-starters - org.springframework.boot - 1.1.0.BUILD-SNAPSHOT - - 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/xsd/maven-4.0.0.xsd"> + + spring-boot-starters + org.springframework.boot + 1.1.0.BUILD-SNAPSHOT + + 4.0.0 - spring-boot-starter-ws - jar - - ${basedir}/../.. - - - - ${project.groupId} - spring-boot-starter - ${project.version} - - - ${project.groupId} - spring-boot-starter-tomcat - ${project.version} - - - org.springframework.ws - spring-ws-core - - - org.springframework.ws - spring-ws-support - - - org.springframework.ws - spring-ws-security - true - - - org.springframework.ws - spring-ws-test - test - - + spring-boot-starter-ws + jar + + ${basedir}/../.. + + + + ${project.groupId} + spring-boot-starter + ${project.version} + + + ${project.groupId} + spring-boot-starter-tomcat + ${project.version} + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + spring-ws-support + + + org.springframework.ws + spring-ws-security + true + + + org.springframework.ws + spring-ws-test + test + + \ No newline at end of file From e40320a8eda1b3cab945ac6258ecbd9761b00d62 Mon Sep 17 00:00:00 2001 From: Maciej Walkowiak Date: Mon, 9 Jun 2014 18:08:16 +0200 Subject: [PATCH 3/4] Added integration test for Spring Web Services Sample project --- .../sample/ws/SampleWsApplicationTests.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java diff --git a/spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java b/spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java new file mode 100644 index 00000000000..da2c3554eb3 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java @@ -0,0 +1,56 @@ +package sample.ws; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.IntegrationTest; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.ws.client.core.WebServiceTemplate; + +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import java.io.StringReader; + +/** + * Tests handling SOAP message + * + * @author Maciej Walkowiak + */ +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = SampleWsApplication.class) +@WebAppConfiguration +@IntegrationTest +public class SampleWsApplicationTests { + private WebServiceTemplate webServiceTemplate = new WebServiceTemplate(); + + @Value("${local.server.port}") + private int serverPort; + + @Before + public void setUp() { + webServiceTemplate.setDefaultUri("http://localhost:" + serverPort + "/services/"); + } + + @Test + public void testSendingHolidayRequest() { + final String request = "" + + " " + + " 2013-10-20" + + " 2013-11-22" + + " " + + " " + + " 1" + + " John" + + " Doe" + + " " + + ""; + + StreamSource source = new StreamSource(new StringReader(request)); + StreamResult result = new StreamResult(System.out); + + webServiceTemplate.sendSourceAndReceiveToResult(source, result); + } +} \ No newline at end of file From b585afe537afd4b0f9a46d7497018c9b730051fe Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 9 Jun 2014 18:03:22 +0100 Subject: [PATCH 4/4] Polishing --- spring-boot-dependencies/pom.xml | 62 +++++++++---------- .../src/main/asciidoc/using-spring-boot.adoc | 4 ++ spring-boot-samples/pom.xml | 2 +- .../spring-boot-sample-ws/README.adoc | 14 +++++ .../spring-boot-sample-ws/README.md | 14 ----- .../spring-boot-sample-ws/pom.xml | 35 +++++------ .../java/sample/ws/SampleWsApplication.java | 18 +++++- .../main/java/sample/ws/WebServiceConfig.java | 22 +++++-- .../sample/ws/endpoint/HolidayEndpoint.java | 58 +++++++++++------ .../ws/service/HumanResourceService.java | 19 +++++- .../ws/service/StubHumanResourceService.java | 26 ++++++-- .../main/resources/META-INF/schemas/hr.xsd | 48 +++++++------- .../sample/ws/SampleWsApplicationTests.java | 35 +++++++---- .../spring-boot-starter-ws/pom.xml | 42 +++++++------ .../main/resources/META-INF/spring.provides | 2 +- spring-boot-versions/pom.xml | 4 ++ 16 files changed, 247 insertions(+), 158 deletions(-) create mode 100644 spring-boot-samples/spring-boot-sample-ws/README.adoc delete mode 100644 spring-boot-samples/spring-boot-sample-ws/README.md diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 8fe4b56bb91..b3baeca2bd0 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -80,7 +80,7 @@ 8.1.15.v20140411 2.2.0.v201112011158 1.1.6 - 2.0.1 + 2.0.5 2.3 1.2.1 1.2 @@ -118,6 +118,7 @@ 7.0.54 1.7 2.0 + 1.6.1 3.0.0 @@ -834,8 +835,8 @@ org.jdom - jdom - ${jdom.version} + jdom2 + ${jdom2.version} org.liquibase @@ -1066,6 +1067,26 @@ spring-social-web ${spring-social.version} + + org.springframework.social + spring-social-facebook + ${spring-social-facebook.version} + + + org.springframework.social + spring-social-facebook-web + ${spring-social-facebook.version} + + + org.springframework.social + spring-social-linkedin + ${spring-social-linkedin.version} + + + org.springframework.social + spring-social-twitter + ${spring-social-twitter.version} + org.springframework.ws spring-ws-core @@ -1110,16 +1131,6 @@ - - wsdl4j - wsdl4j - 1.6.3 - - - xmlunit - xmlunit - 1.5 - org.thymeleaf thymeleaf @@ -1135,26 +1146,6 @@ thymeleaf-extras-springsecurity3 ${thymeleaf-extras-springsecurity3.version} - - org.springframework.social - spring-social-facebook - ${spring-social-facebook.version} - - - org.springframework.social - spring-social-facebook-web - ${spring-social-facebook.version} - - - org.springframework.social - spring-social-twitter - ${spring-social-twitter.version} - - - org.springframework.social - spring-social-linkedin - ${spring-social-linkedin.version} - org.yaml snakeyaml @@ -1165,6 +1156,11 @@ jedis ${jedis.version} + + wsdl4j + wsdl4j + ${wsdl4j.version} + diff --git a/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc b/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc index b7a67803f0e..fdb1e1a531e 100644 --- a/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc +++ b/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc @@ -289,6 +289,10 @@ and Hibernate. |Support for websocket development with Tomcat. |=== +|`spring-boot-starter-ws` +|Support for Spring Web Services +|=== + In addition to the application starters, the following starters can be used to add '<>' features. diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index bb1a34e969d..627d535af17 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -56,8 +56,8 @@ spring-boot-sample-web-ui spring-boot-sample-web-velocity spring-boot-sample-websocket + spring-boot-sample-ws spring-boot-sample-xml - spring-boot-sample-ws diff --git a/spring-boot-samples/spring-boot-sample-ws/README.adoc b/spring-boot-samples/spring-boot-sample-ws/README.adoc new file mode 100644 index 00000000000..051ac85e151 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/README.adoc @@ -0,0 +1,14 @@ +== Spring Boot - Samples - Web Services + +This sample project demonstrates how to use http://projects.spring.io/spring-ws/[Spring Web Services] +with Spring Boot. It is an implementation of the +http://docs.spring.io/spring-ws/site/reference/html/tutorial.html#tutorial.implementing.endpoint[Holiday Request sample] +in the Spring Web Services reference guilde. + +The sample uses Maven. It can be built and run from the command line: + +---- +$ mvn spring-boot:run +---- + +http://localhost:8080/services/holidayService/holiday.wsdl will now display the generated WSDL. \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-ws/README.md b/spring-boot-samples/spring-boot-sample-ws/README.md deleted file mode 100644 index 40e58611053..00000000000 --- a/spring-boot-samples/spring-boot-sample-ws/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Spring Boot - Samples - Web Services - -This sample project demonstrates how to bootstrap and use Spring Web Services with Spring Boot. - -It is a runnable implementation of the HolidayRequest sample in the Spring Web Services [reference guide](http://docs.spring.io/spring-ws/site/reference/html/tutorial.html#tutorial.implementing.endpoint). - -The sample can be build with Maven (>3) and simply run from the command line. - -``` -$ mvn package -$ java -jar target/*.jar -``` - -Now pointing your browser to [http://localhost:8080/services/holidayService/holiday.wsdl] should display the generated WSDL. \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-ws/pom.xml b/spring-boot-samples/spring-boot-sample-ws/pom.xml index 2e6ef4e07c1..61706f1fc31 100644 --- a/spring-boot-samples/spring-boot-sample-ws/pom.xml +++ b/spring-boot-samples/spring-boot-sample-ws/pom.xml @@ -1,45 +1,44 @@ - + + 4.0.0 + spring-boot-samples org.springframework.boot 1.1.0.BUILD-SNAPSHOT - 4.0.0 - spring-boot-sample-ws - + Spring Boot Web Services Sample + Spring Boot Web Services Sample + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + ${basedir}/../.. - 1.7 org.springframework.boot - spring-boot-starter-ws + spring-boot-starter-test + test org.springframework.boot - spring-boot-starter-actuator - - - org.jdom - jdom + spring-boot-starter-ws jaxen jaxen - wsdl4j - wsdl4j + org.jdom + jdom2 - ${project.groupId} - spring-boot-starter-test - test + wsdl4j + wsdl4j diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java index 5dd802eaf1d..35f5056084e 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java @@ -1,3 +1,18 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package sample.ws; import org.springframework.boot.SpringApplication; @@ -5,9 +20,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -/** - * Created by in329dei on 28-2-14. - */ @Configuration @EnableAutoConfiguration @ComponentScan diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java index 9935f7537b5..b6ac0a6f082 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package sample.ws; import org.springframework.boot.context.embedded.ServletRegistrationBean; @@ -12,19 +27,14 @@ import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; import org.springframework.xml.xsd.SimpleXsdSchema; import org.springframework.xml.xsd.XsdSchema; -/** - * Configures Spring Web Service components - * - * @author Maciej Walkowiak - */ @EnableWs @Configuration public class WebServiceConfig extends WsConfigurerAdapter { + @Bean public ServletRegistrationBean dispatcherServlet(ApplicationContext applicationContext) { MessageDispatcherServlet servlet = new MessageDispatcherServlet(); servlet.setApplicationContext(applicationContext); - return new ServletRegistrationBean(servlet, "/services/*"); } diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java index 606367974fa..db86e0dd2e5 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java @@ -1,5 +1,26 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package sample.ws.endpoint; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactoryConfigurationException; + import org.jdom2.Element; import org.jdom2.JDOMException; import org.jdom2.Namespace; @@ -10,17 +31,9 @@ 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 sample.ws.service.HumanResourceService; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactoryConfigurationException; -import java.text.SimpleDateFormat; -import java.util.Date; +import sample.ws.service.HumanResourceService; -/** - * @author in329dei - * @author Maciej Walkowiak - */ @Endpoint public class HolidayEndpoint { @@ -33,25 +46,34 @@ public class HolidayEndpoint { private HumanResourceService humanResourceService; @Autowired - public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException, XPathFactoryConfigurationException, XPathExpressionException { + public HolidayEndpoint(HumanResourceService humanResourceService) + throws JDOMException, XPathFactoryConfigurationException, + XPathExpressionException { this.humanResourceService = humanResourceService; Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI); XPathFactory xPathFactory = XPathFactory.instance(); - startDateExpression = xPathFactory.compile("//hr:StartDate", Filters.element(), null, namespace); - endDateExpression = xPathFactory.compile("//hr:EndDate", Filters.element(), null, namespace); - nameExpression = xPathFactory.compile("concat(//hr:FirstName,' ',//hr:LastName)", Filters.fstring(), null, namespace); + this.startDateExpression = xPathFactory.compile("//hr:StartDate", + Filters.element(), null, namespace); + this.endDateExpression = xPathFactory.compile("//hr:EndDate", Filters.element(), + null, namespace); + this.nameExpression = xPathFactory.compile( + "concat(//hr:FirstName,' ',//hr:LastName)", Filters.fstring(), null, + namespace); } @PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest") - public void handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception { + public void handleHolidayRequest(@RequestPayload Element holidayRequest) + throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date startDate = dateFormat.parse(startDateExpression.evaluateFirst(holidayRequest).getText()); - Date endDate = dateFormat.parse(endDateExpression.evaluateFirst(holidayRequest).getText()); - String name = nameExpression.evaluateFirst(holidayRequest); + Date startDate = dateFormat.parse(this.startDateExpression.evaluateFirst( + holidayRequest).getText()); + Date endDate = dateFormat.parse(this.endDateExpression.evaluateFirst( + holidayRequest).getText()); + String name = this.nameExpression.evaluateFirst(holidayRequest); - humanResourceService.bookHoliday(startDate, endDate, name); + this.humanResourceService.bookHoliday(startDate, endDate, name); } } diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java index 5f7c7416099..4289d70cda8 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java @@ -1,10 +1,23 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package sample.ws.service; import java.util.Date; -/** - * Created by in329dei on 28-2-14. - */ public interface HumanResourceService { + void bookHoliday(Date startDate, Date endDate, String name); } diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java index 0f030889cf6..5d3fdc071c2 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java @@ -1,20 +1,34 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package sample.ws.service; +import java.util.Date; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; -import java.util.Date; - -/** - * Created by in329dei on 28-2-14. - */ @Service public class StubHumanResourceService implements HumanResourceService { + private final Logger logger = LoggerFactory.getLogger(StubHumanResourceService.class); @Override public void bookHoliday(Date startDate, Date endDate, String name) { - logger.info("Booking holiday for [{} - {}] for [{}] ", startDate, endDate, name); + this.logger.info("Booking holiday for [{} - {}] for [{}] ", startDate, endDate, + name); } } diff --git a/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/schemas/hr.xsd b/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/schemas/hr.xsd index eed94778e2e..860ba4e59b5 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/schemas/hr.xsd +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/resources/META-INF/schemas/hr.xsd @@ -1,26 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - + xmlns:hr="http://mycompany.com/hr/schemas" + elementFormDefault="qualified" + targetNamespace="http://mycompany.com/hr/schemas"> + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java b/spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java index da2c3554eb3..055db790e1b 100644 --- a/spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java @@ -1,5 +1,25 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package sample.ws; +import java.io.StringReader; + +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -10,20 +30,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.ws.client.core.WebServiceTemplate; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -import java.io.StringReader; - -/** - * Tests handling SOAP message - * - * @author Maciej Walkowiak - */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SampleWsApplication.class) @WebAppConfiguration @IntegrationTest public class SampleWsApplicationTests { + private WebServiceTemplate webServiceTemplate = new WebServiceTemplate(); @Value("${local.server.port}") @@ -31,7 +43,8 @@ public class SampleWsApplicationTests { @Before public void setUp() { - webServiceTemplate.setDefaultUri("http://localhost:" + serverPort + "/services/"); + this.webServiceTemplate.setDefaultUri("http://localhost:" + this.serverPort + + "/services/"); } @Test @@ -51,6 +64,6 @@ public class SampleWsApplicationTests { StreamSource source = new StreamSource(new StringReader(request)); StreamResult result = new StreamResult(System.out); - webServiceTemplate.sendSourceAndReceiveToResult(source, result); + this.webServiceTemplate.sendSourceAndReceiveToResult(source, result); } } \ No newline at end of file diff --git a/spring-boot-starters/spring-boot-starter-ws/pom.xml b/spring-boot-starters/spring-boot-starter-ws/pom.xml index 5c3600a5b87..c52b2f6c490 100644 --- a/spring-boot-starters/spring-boot-starter-ws/pom.xml +++ b/spring-boot-starters/spring-boot-starter-ws/pom.xml @@ -2,47 +2,49 @@ + 4.0.0 - spring-boot-starters org.springframework.boot + spring-boot-starters 1.1.0.BUILD-SNAPSHOT - 4.0.0 - spring-boot-starter-ws - jar + Spring Boot Web Services Starter + Spring Boot Web Services Starter + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + ${basedir}/../.. - ${project.groupId} + org.springframework.boot spring-boot-starter - ${project.version} - - - ${project.groupId} - spring-boot-starter-tomcat - ${project.version} - org.springframework.ws - spring-ws-core + org.springframework.boot + spring-boot-starter-web - org.springframework.ws - spring-ws-support + org.springframework + spring-core + + + commons-logging + commons-logging + + org.springframework.ws - spring-ws-security - true + spring-ws-core org.springframework.ws - spring-ws-test - test + spring-ws-support - \ No newline at end of file diff --git a/spring-boot-starters/spring-boot-starter-ws/src/main/resources/META-INF/spring.provides b/spring-boot-starters/spring-boot-starter-ws/src/main/resources/META-INF/spring.provides index 9a488a0a6dc..e7486ed01df 100644 --- a/spring-boot-starters/spring-boot-starter-ws/src/main/resources/META-INF/spring.provides +++ b/spring-boot-starters/spring-boot-starter-ws/src/main/resources/META-INF/spring.provides @@ -1 +1 @@ -provides: spring-ws-core,spring-ws-support,spring-ws-security \ No newline at end of file +provides: spring-ws-core,spring-ws-support \ No newline at end of file diff --git a/spring-boot-versions/pom.xml b/spring-boot-versions/pom.xml index 63160430b0a..8e67d18599f 100644 --- a/spring-boot-versions/pom.xml +++ b/spring-boot-versions/pom.xml @@ -273,5 +273,9 @@ org.springframework.boot spring-boot-starter-websocket + + org.springframework.boot + spring-boot-starter-ws +