diff --git a/echo/build.gradle b/echo/build.gradle index 5736641..71bee7a 100644 --- a/echo/build.gradle +++ b/echo/build.gradle @@ -1,3 +1,5 @@ +ext.springWsVersion = '2.2.0.BUILD-SNAPSHOT' + subprojects { apply plugin: 'java' apply plugin: 'eclipse' @@ -5,6 +7,7 @@ subprojects { repositories { maven { url 'http://repo.spring.io/libs-release' } + maven { url 'http://repo.spring.io/libs-snapshot' } } dependencies { @@ -13,7 +16,3 @@ subprojects { } } - -task wrapper(type: Wrapper) { - gradleVersion = '1.8' -} diff --git a/echo/client/spring-ws/build.gradle b/echo/client/spring-ws/build.gradle index bdb18be..688d104 100644 --- a/echo/client/spring-ws/build.gradle +++ b/echo/client/spring-ws/build.gradle @@ -1,5 +1,3 @@ -ext.springWsVersion = '2.1.4.RELEASE' - dependencies { compile("org.springframework.ws:spring-ws-core:$springWsVersion") runtime("log4j:log4j:1.2.16") @@ -8,4 +6,4 @@ dependencies { task runClient(dependsOn: 'classes', type:JavaExec) { main = "org.springframework.ws.samples.echo.client.sws.EchoClient" classpath = sourceSets.main.runtimeClasspath -} \ No newline at end of file +} diff --git a/echo/client/spring-ws/src/main/java/org/springframework/ws/samples/echo/client/sws/EchoClient.java b/echo/client/spring-ws/src/main/java/org/springframework/ws/samples/echo/client/sws/EchoClient.java index 6eb79a9..764e21f 100644 --- a/echo/client/spring-ws/src/main/java/org/springframework/ws/samples/echo/client/sws/EchoClient.java +++ b/echo/client/spring-ws/src/main/java/org/springframework/ws/samples/echo/client/sws/EchoClient.java @@ -21,6 +21,7 @@ import javax.xml.transform.Source; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.ws.client.core.support.WebServiceGatewaySupport; import org.springframework.xml.transform.ResourceSource; @@ -44,9 +45,11 @@ public class EchoClient extends WebServiceGatewaySupport { } public static void main(String[] args) throws IOException { - ApplicationContext applicationContext = - new ClassPathXmlApplicationContext("applicationContext.xml", EchoClient.class); - EchoClient echoClient = (EchoClient) applicationContext.getBean("echoClient"); + EchoClient echoClient = new EchoClient(); + echoClient.setDefaultUri("http://localhost:8080/echo-server/services"); + echoClient.setRequest(new ClassPathResource( + "org/springframework/ws/samples/echo/client/sws/echoRequest.xml")); + echoClient.echo(); } diff --git a/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/applicationContext.xml b/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/applicationContext.xml deleted file mode 100644 index 21376fc..0000000 --- a/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/applicationContext.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/echo/server/build.gradle b/echo/server/build.gradle index 9ee0f89..544ff6a 100644 --- a/echo/server/build.gradle +++ b/echo/server/build.gradle @@ -1,31 +1,38 @@ buildscript { repositories { - mavenCentral() + maven { url 'http://repo.springsource.org/plugins-release' } } dependencies { - classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:0.9.9' + classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:0.9.9' } } -ext.springVersion = '3.2.4.RELEASE' -ext.springWsVersion = '2.1.4.RELEASE' +ext.springVersion = '4.0.2.RELEASE' ext.tomcatVersion = '7.0.42' apply plugin: 'war' +apply plugin: 'maven' apply plugin: 'tomcat' tomcatRun { contextPath = 'echo-server' } +repositories { + mavenLocal() +} dependencies { compile("org.springframework.ws:spring-ws-core:$springWsVersion") + compile("org.springframework:spring-context:$springVersion") runtime("log4j:log4j:1.2.16") + providedCompile("javax.servlet:javax.servlet-api:3.0.1") + runtime("wsdl4j:wsdl4j:1.6.1") + tomcat("org.apache.tomcat.embed:tomcat-embed-core:$tomcatVersion", "org.apache.tomcat.embed:tomcat-embed-logging-juli:$tomcatVersion") tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:$tomcatVersion") { exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj' } -} \ No newline at end of file +} diff --git a/echo/server/src/main/java/org/springframework/ws/samples/echo/config/EchoConfig.java b/echo/server/src/main/java/org/springframework/ws/samples/echo/config/EchoConfig.java new file mode 100644 index 0000000..068cd2e --- /dev/null +++ b/echo/server/src/main/java/org/springframework/ws/samples/echo/config/EchoConfig.java @@ -0,0 +1,68 @@ +/* + * Copyright 2005-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 org.springframework.ws.samples.echo.config; + +import java.util.List; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +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.server.EndpointInterceptor; +import org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor; +import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor; +import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; +import org.springframework.xml.xsd.SimpleXsdSchema; + +/** + * Configuration class for the Echo sample. + * + * @author Arjen Poutsma + */ +@EnableWs +@Configuration +@ComponentScan("org.springframework.ws.samples.echo") +public class EchoConfig extends WsConfigurerAdapter { + + @Bean + public SimpleXsdSchema echoXsd() { + return new SimpleXsdSchema(new ClassPathResource("echo.xsd")); + } + + @Override + public void addInterceptors(List interceptors) { + PayloadValidatingInterceptor validatingInterceptor = new PayloadValidatingInterceptor(); + validatingInterceptor.setXsdSchema(echoXsd()); + validatingInterceptor.setValidateRequest(true); + validatingInterceptor.setValidateResponse(true); + interceptors.add(validatingInterceptor); + + interceptors.add(new PayloadLoggingInterceptor()); + } + + @Bean + public DefaultWsdl11Definition echo() { + DefaultWsdl11Definition definition = new DefaultWsdl11Definition(); + definition.setPortTypeName("Echo"); + definition.setLocationUri("http://localhost:8080/echo/services"); + definition.setSchema(echoXsd()); + + return definition; + } +} diff --git a/echo/server/src/main/java/org/springframework/ws/samples/echo/config/EchoServletInitializer.java b/echo/server/src/main/java/org/springframework/ws/samples/echo/config/EchoServletInitializer.java new file mode 100644 index 0000000..30469bc --- /dev/null +++ b/echo/server/src/main/java/org/springframework/ws/samples/echo/config/EchoServletInitializer.java @@ -0,0 +1,43 @@ +/* + * Copyright 2005-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 org.springframework.ws.samples.echo.config; + +import org.springframework.web.WebApplicationInitializer; +import org.springframework.ws.transport.http.support.AbstractAnnotationConfigMessageDispatcherServletInitializer; + +/** + * {@link WebApplicationInitializer} for the echo sample. + * @author Arjen Poutsma + */ +public class EchoServletInitializer + extends AbstractAnnotationConfigMessageDispatcherServletInitializer { + + @Override + protected Class[] getRootConfigClasses() { + return null; + } + + @Override + protected Class[] getServletConfigClasses() { + return new Class[]{EchoConfig.class}; + } + + @Override + public boolean isTransformWsdlLocations() { + return true; + } +} diff --git a/echo/server/src/main/webapp/WEB-INF/echo.xsd b/echo/server/src/main/resources/echo.xsd similarity index 75% rename from echo/server/src/main/webapp/WEB-INF/echo.xsd rename to echo/server/src/main/resources/echo.xsd index 1fac4c1..be815cb 100644 --- a/echo/server/src/main/webapp/WEB-INF/echo.xsd +++ b/echo/server/src/main/resources/echo.xsd @@ -1,7 +1,7 @@ - + diff --git a/echo/server/src/main/webapp/EMTPY b/echo/server/src/main/webapp/EMTPY new file mode 100644 index 0000000..e69de29 diff --git a/echo/server/src/main/webapp/WEB-INF/spring-ws-servlet.xml b/echo/server/src/main/webapp/WEB-INF/spring-ws-servlet.xml deleted file mode 100755 index fd4b06a..0000000 --- a/echo/server/src/main/webapp/WEB-INF/spring-ws-servlet.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - This web application context contains Spring-WS beans. The beans defined in this context are automatically - detected by Spring-WS, similar to the way Controllers are picked up in Spring Web MVC. - - - - - - - - - - This interceptor validates both incoming and outgoing message contents according to the 'echo.xsd' XML - Schema file. - - - - - - - - This interceptor logs the message payload. - - - - - - - - - \ No newline at end of file diff --git a/echo/server/src/main/webapp/WEB-INF/web.xml b/echo/server/src/main/webapp/WEB-INF/web.xml deleted file mode 100755 index 2c60c8c..0000000 --- a/echo/server/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - "Echo" WebService - - Returns a given string(only A-Z and a-z chars allowed). See echo.xsd file. - - - - spring-ws - org.springframework.ws.transport.http.MessageDispatcherServlet - - - transformWsdlLocations - true - - - - - - spring-ws - /* - - - \ No newline at end of file