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 798126d63f5..b3baeca2bd0 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.5 2.3 1.2.1 1.2 @@ -109,12 +111,14 @@ 1.0.1.RELEASE 3.2.4.RELEASE 1.0.2.RELEASE + 2.2.0.RELEASE 2.1.3.RELEASE 2.1.1.RELEASE 1.2.4 7.0.54 1.7 2.0 + 1.6.1 3.0.0 @@ -330,6 +334,11 @@ spring-boot-starter-websocket 1.1.0.BUILD-SNAPSHOT + + org.springframework.boot + spring-boot-starter-ws + 1.1.0.BUILD-SNAPSHOT + @@ -454,6 +463,11 @@ jstl ${jstl.version} + + jaxen + jaxen + ${jaxen.version} + joda-time joda-time @@ -819,6 +833,11 @@ jolokia-core ${jolokia.version} + + org.jdom + jdom2 + ${jdom2.version} + org.liquibase liquibase-core @@ -1058,31 +1077,75 @@ 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.social - spring-social-linkedin - ${spring-social-linkedin.version} + org.springframework.ws + spring-ws-core + ${spring-ws.version} + + + commons-logging + commons-logging + + + + + org.springframework.ws + spring-ws-support + ${spring-ws.version} + + + commons-logging + commons-logging + + + + + 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 + + org.thymeleaf thymeleaf ${thymeleaf.version} - - org.thymeleaf.extras - thymeleaf-extras-springsecurity3 - ${thymeleaf-extras-springsecurity3.version} - org.thymeleaf thymeleaf-spring4 ${thymeleaf.version} + + org.thymeleaf.extras + thymeleaf-extras-springsecurity3 + ${thymeleaf-extras-springsecurity3.version} + org.yaml snakeyaml @@ -1093,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 18e2cc5135d..627d535af17 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -56,8 +56,9 @@ spring-boot-sample-web-ui spring-boot-sample-web-velocity spring-boot-sample-websocket + spring-boot-sample-ws spring-boot-sample-xml - + 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/pom.xml b/spring-boot-samples/spring-boot-sample-ws/pom.xml new file mode 100644 index 00000000000..61706f1fc31 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + + spring-boot-samples + org.springframework.boot + 1.1.0.BUILD-SNAPSHOT + + 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}/../.. + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-ws + + + jaxen + jaxen + + + org.jdom + jdom2 + + + wsdl4j + wsdl4j + + + + + + 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..35f5056084e --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/SampleWsApplication.java @@ -0,0 +1,31 @@ +/* + * 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; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableAutoConfiguration +@ComponentScan +public class SampleWsApplication { + + 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..b6ac0a6f082 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/WebServiceConfig.java @@ -0,0 +1,55 @@ +/* + * 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; +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; + +@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 new file mode 100644 index 00000000000..db86e0dd2e5 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/endpoint/HolidayEndpoint.java @@ -0,0 +1,79 @@ +/* + * 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; +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; + +@Endpoint +public class HolidayEndpoint { + + private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas"; + + private XPathExpression startDateExpression; + private XPathExpression endDateExpression; + private XPathExpression nameExpression; + + private HumanResourceService humanResourceService; + + @Autowired + public HolidayEndpoint(HumanResourceService humanResourceService) + throws JDOMException, XPathFactoryConfigurationException, + XPathExpressionException { + this.humanResourceService = humanResourceService; + + Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI); + + XPathFactory xPathFactory = XPathFactory.instance(); + + 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 { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date startDate = dateFormat.parse(this.startDateExpression.evaluateFirst( + holidayRequest).getText()); + Date endDate = dateFormat.parse(this.endDateExpression.evaluateFirst( + holidayRequest).getText()); + String name = this.nameExpression.evaluateFirst(holidayRequest); + + 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 new file mode 100644 index 00000000000..4289d70cda8 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/HumanResourceService.java @@ -0,0 +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; + +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..5d3fdc071c2 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/main/java/sample/ws/service/StubHumanResourceService.java @@ -0,0 +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; + +@Service +public class StubHumanResourceService implements HumanResourceService { + + private final Logger logger = LoggerFactory.getLogger(StubHumanResourceService.class); + + @Override + public void bookHoliday(Date startDate, Date endDate, String 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 new file mode 100644 index 00000000000..860ba4e59b5 --- /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/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..055db790e1b --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ws/src/test/java/sample/ws/SampleWsApplicationTests.java @@ -0,0 +1,69 @@ +/* + * 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; +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; + +@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() { + this.webServiceTemplate.setDefaultUri("http://localhost:" + this.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); + + this.webServiceTemplate.sendSourceAndReceiveToResult(source, result); + } +} \ 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..c52b2f6c490 --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-ws/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starters + 1.1.0.BUILD-SNAPSHOT + + spring-boot-starter-ws + Spring Boot Web Services Starter + Spring Boot Web Services Starter + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + + + ${basedir}/../.. + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-core + + + commons-logging + commons-logging + + + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + 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 new file mode 100644 index 00000000000..e7486ed01df --- /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 \ 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 +