diff --git a/.gitignore b/.gitignore
index b2200cd..c2b1080 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,6 @@ atlassian-ide-plugin*.xml
/build
/*/build
+/*/*/build
+/*/*/*/build
.gradle
diff --git a/README.md b/README.md
index 6595073..5881c5f 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,47 @@
-spring-ws-samples
-=================
+# Spring Web Services Samples
+
+[Spring Web Services] is a product of the Spring community focused on creating
+document-driven, contract-first Web services. This repository contains sample
+projects illustrating usage of Spring Web Services.
+
+## Sample Applications
+
+The following sample applications demonstrate the capabilities of [Spring Web
+Services]. See the README within each sample project for more information and
+additional instructions.
+
+- [echo](./echo) - a simple sample that shows a bare-bones Echo service
+- [tutorial](./tutorial) - contains the code from the Spring-WS tutorial
+
+## Running the Server
+
+Most of the sample apps can be built and run using the following commands from
+within the sample's folder.
+
+ ```sh
+ $ ./gradlew tomcatRun
+ ```
+
+Or alternatively, run the following to create war archive which can be deployed
+in any Web Container.
+
+ ```sh
+ $ ./gradlew war
+ ```
+
+## Running the Client(s)
+
+Most of the sample apps have a separate ``client`` directory containing clients
+that connect to the server. You can run these clients by using the following
+command from within each of client subdirectories:
+
+ ```sh
+ $ gradle runClient
+ ```
+
+## License
+
+[Spring Web Services] is released under version 2.0 of the [Apache License].
+
+[Spring Web Services]: http://projects.spring.io/spring-ws
+[Apache License]: http://www.apache.org/licenses/LICENSE-2.0
diff --git a/echo/README.md b/echo/README.md
new file mode 100644
index 0000000..4f60173
--- /dev/null
+++ b/echo/README.md
@@ -0,0 +1,15 @@
+# Spring Web Service Tutorial
+
+This sample shows a bare-bones echoing service. Incoming messages are handled
+via DOM, and a simple 'business logic' service is used to obtain the result.
+
+## Build and deploy
+
+See the main [README](../README.md) for build instructions.
+
+## License
+
+[Spring Web Services] is released under version 2.0 of the [Apache License].
+
+[Spring Web Services]: http://projects.spring.io/spring-ws
+[Apache License]: http://www.apache.org/licenses/LICENSE-2.0
\ No newline at end of file
diff --git a/echo/build.gradle b/echo/build.gradle
new file mode 100644
index 0000000..698d3a6
--- /dev/null
+++ b/echo/build.gradle
@@ -0,0 +1,29 @@
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:0.9.9'
+ }
+}
+
+subprojects {
+ apply plugin: 'java'
+ apply plugin: 'eclipse'
+ apply plugin: 'idea'
+
+ repositories {
+ maven { url 'http://repo.spring.io/libs-release' }
+ }
+
+ dependencies {
+ testCompile("junit:junit:4.10")
+ testCompile("org.easymock:easymock:3.1")
+ }
+
+}
+
+task wrapper(type: Wrapper) {
+ gradleVersion = '1.8'
+}
diff --git a/echo/client/saaj/build.gradle b/echo/client/saaj/build.gradle
new file mode 100644
index 0000000..5987bbd
--- /dev/null
+++ b/echo/client/saaj/build.gradle
@@ -0,0 +1,4 @@
+task runClient(dependsOn: 'classes', type:JavaExec) {
+ main = "org.springframework.ws.samples.echo.client.saaj.EchoClient"
+ classpath = sourceSets.main.runtimeClasspath
+}
\ No newline at end of file
diff --git a/echo/client/saaj/src/main/java/org/springframework/ws/samples/echo/client/saaj/EchoClient.java b/echo/client/saaj/src/main/java/org/springframework/ws/samples/echo/client/saaj/EchoClient.java
new file mode 100644
index 0000000..a8ee4f2
--- /dev/null
+++ b/echo/client/saaj/src/main/java/org/springframework/ws/samples/echo/client/saaj/EchoClient.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2006 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.client.saaj;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+
+/**
+ * A client for the Echo Web Service that uses SAAJ.
+ *
+ * @author Ben Ethridge
+ * @author Arjen Poutsma
+ */
+public class EchoClient {
+
+ public static final String NAMESPACE_URI = "http://www.springframework.org/spring-ws/samples/echo";
+
+ public static final String PREFIX = "tns";
+
+ private SOAPConnectionFactory connectionFactory;
+
+ private MessageFactory messageFactory;
+
+ private URL url;
+
+ public EchoClient(String url) throws SOAPException, MalformedURLException {
+ connectionFactory = SOAPConnectionFactory.newInstance();
+ messageFactory = MessageFactory.newInstance();
+ this.url = new URL(url);
+ }
+
+ private SOAPMessage createEchoRequest() throws SOAPException {
+ SOAPMessage message = messageFactory.createMessage();
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ Name echoRequestName = envelope.createName("echoRequest", PREFIX, NAMESPACE_URI);
+ SOAPBodyElement echoRequestElement = message.getSOAPBody()
+ .addBodyElement(echoRequestName);
+ echoRequestElement.setValue("Hello");
+ return message;
+ }
+
+ public void callWebService() throws SOAPException, IOException {
+ SOAPMessage request = createEchoRequest();
+ SOAPConnection connection = connectionFactory.createConnection();
+ SOAPMessage response = connection.call(request, url);
+ if (!response.getSOAPBody().hasFault()) {
+ writeEchoResponse(response);
+ }
+ else {
+ SOAPFault fault = response.getSOAPBody().getFault();
+ System.err.println("Received SOAP Fault");
+ System.err.println("SOAP Fault Code :" + fault.getFaultCode());
+ System.err.println("SOAP Fault String :" + fault.getFaultString());
+ }
+ }
+
+ private void writeEchoResponse(SOAPMessage message) throws SOAPException {
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ Name echoResponseName = envelope.createName("echoResponse", PREFIX, NAMESPACE_URI);
+ SOAPBodyElement echoResponseElement = (SOAPBodyElement) message
+ .getSOAPBody().getChildElements(echoResponseName).next();
+ String echoValue = echoResponseElement.getTextContent();
+ System.out.println();
+ System.out.println("Echo Response [" + echoValue + "]");
+ System.out.println();
+ }
+
+ public static void main(String[] args) throws Exception {
+ String url = "http://localhost:8080/echo-server/services";
+ if (args.length > 0) {
+ url = args[0];
+ }
+ EchoClient echoClient = new EchoClient(url);
+ echoClient.callWebService();
+ }
+}
\ No newline at end of file
diff --git a/echo/client/spring-ws/build.gradle b/echo/client/spring-ws/build.gradle
new file mode 100644
index 0000000..bdb18be
--- /dev/null
+++ b/echo/client/spring-ws/build.gradle
@@ -0,0 +1,11 @@
+ext.springWsVersion = '2.1.4.RELEASE'
+
+dependencies {
+ compile("org.springframework.ws:spring-ws-core:$springWsVersion")
+ runtime("log4j:log4j:1.2.16")
+}
+
+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
new file mode 100644
index 0000000..6eb79a9
--- /dev/null
+++ b/echo/client/spring-ws/src/main/java/org/springframework/ws/samples/echo/client/sws/EchoClient.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 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.client.sws;
+
+import java.io.IOException;
+import javax.xml.transform.Source;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.core.io.Resource;
+import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
+import org.springframework.xml.transform.ResourceSource;
+import org.springframework.xml.transform.StringResult;
+
+public class EchoClient extends WebServiceGatewaySupport {
+
+ private Resource request;
+
+ public void setRequest(Resource request) {
+ this.request = request;
+ }
+
+ public void echo() throws IOException {
+ Source requestSource = new ResourceSource(request);
+ StringResult result = new StringResult();
+ getWebServiceTemplate().sendSourceAndReceiveToResult(requestSource, result);
+ System.out.println();
+ System.out.println(result);
+ System.out.println();
+ }
+
+ public static void main(String[] args) throws IOException {
+ ApplicationContext applicationContext =
+ new ClassPathXmlApplicationContext("applicationContext.xml", EchoClient.class);
+ EchoClient echoClient = (EchoClient) applicationContext.getBean("echoClient");
+ echoClient.echo();
+ }
+
+}
diff --git a/echo/client/spring-ws/src/main/resources/log4j.properties b/echo/client/spring-ws/src/main/resources/log4j.properties
new file mode 100644
index 0000000..0f73a75
--- /dev/null
+++ b/echo/client/spring-ws/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+log4j.rootLogger=WARN, stdout
+log4j.logger.org.springframework.ws=DEBUG
+log4j.logger.org.springframework.xml=DEBUG
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
\ No newline at end of file
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
new file mode 100644
index 0000000..21376fc
--- /dev/null
+++ b/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/applicationContext.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
diff --git a/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/echoRequest.xml b/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/echoRequest.xml
new file mode 100644
index 0000000..36da948
--- /dev/null
+++ b/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/echoRequest.xml
@@ -0,0 +1,2 @@
+
+Hello
diff --git a/echo/server/build.gradle b/echo/server/build.gradle
new file mode 100644
index 0000000..a55411f
--- /dev/null
+++ b/echo/server/build.gradle
@@ -0,0 +1,21 @@
+ext.springVersion = '3.2.4.RELEASE'
+ext.springWsVersion = '2.1.4.RELEASE'
+ext.tomcatVersion = '7.0.42'
+
+apply plugin: 'war'
+apply plugin: 'tomcat'
+
+tomcatRun {
+ contextPath = 'echo-server'
+}
+
+dependencies {
+ compile("org.springframework.ws:spring-ws-core:$springWsVersion")
+ runtime("log4j:log4j:1.2.16")
+
+ 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/service/EchoService.java b/echo/server/src/main/java/org/springframework/ws/samples/echo/service/EchoService.java
new file mode 100644
index 0000000..602adee
--- /dev/null
+++ b/echo/server/src/main/java/org/springframework/ws/samples/echo/service/EchoService.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 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.service;
+
+/**
+ * Defines the "business logic" of the web service.
+ *
+ * @author Ingo Siebert
+ * @author Arjen Poutsma
+ */
+public interface EchoService {
+
+ /**
+ * Returns the given string.
+ *
+ * @return s
+ */
+ String echo(String s);
+}
diff --git a/echo/server/src/main/java/org/springframework/ws/samples/echo/service/impl/EchoServiceImpl.java b/echo/server/src/main/java/org/springframework/ws/samples/echo/service/impl/EchoServiceImpl.java
new file mode 100755
index 0000000..7be65d2
--- /dev/null
+++ b/echo/server/src/main/java/org/springframework/ws/samples/echo/service/impl/EchoServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2005-2010 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.service.impl;
+
+import org.springframework.stereotype.Service;
+import org.springframework.ws.samples.echo.service.EchoService;
+
+/**
+ * Default implementation of EchoService.
+ *
+ * @author Ingo Siebert
+ * @author Arjen Poutsma
+ */
+@Service
+public class EchoServiceImpl implements EchoService {
+
+ public String echo(String s) {
+ return s;
+ }
+}
diff --git a/echo/server/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java b/echo/server/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java
new file mode 100755
index 0000000..f1e7327
--- /dev/null
+++ b/echo/server/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2005-2010 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.ws;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.Assert;
+import org.springframework.ws.samples.echo.service.EchoService;
+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 org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * Simple echoing Web service endpoint. Uses a EchoService to create a response string.
+ *
+ * @author Ingo Siebert
+ * @author Arjen Poutsma
+ */
+@Endpoint
+public class EchoEndpoint {
+
+ /**
+ * Namespace of both request and response.
+ */
+ public static final String NAMESPACE_URI = "http://www.springframework.org/spring-ws/samples/echo";
+
+ /**
+ * The local name of the expected request.
+ */
+ public static final String ECHO_REQUEST_LOCAL_NAME = "echoRequest";
+
+ /**
+ * The local name of the created response.
+ */
+ public static final String ECHO_RESPONSE_LOCAL_NAME = "echoResponse";
+
+ private final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+
+ private final EchoService echoService;
+
+ @Autowired
+ public EchoEndpoint(EchoService echoService) {
+ this.echoService = echoService;
+ }
+
+
+ /**
+ * Reads the given requestElement, and sends a the response back.
+ *
+ * @param requestElement the contents of the SOAP message as DOM elements
+ * @return the response element
+ */
+ @PayloadRoot(localPart = ECHO_REQUEST_LOCAL_NAME, namespace = NAMESPACE_URI)
+ @ResponsePayload
+ public Element handleEchoRequest(@RequestPayload Element requestElement) throws ParserConfigurationException {
+ Assert.isTrue(NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace");
+ Assert.isTrue(ECHO_REQUEST_LOCAL_NAME.equals(requestElement.getLocalName()), "Invalid local name");
+
+ NodeList children = requestElement.getChildNodes();
+ Text requestText = null;
+ for (int i = 0; i < children.getLength(); i++) {
+ if (children.item(i).getNodeType() == Node.TEXT_NODE) {
+ requestText = (Text) children.item(i);
+ break;
+ }
+ }
+ if (requestText == null) {
+ throw new IllegalArgumentException("Could not find request text node");
+ }
+
+ String echo = echoService.echo(requestText.getNodeValue());
+
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ Document document = documentBuilder.newDocument();
+ Element responseElement = document.createElementNS(NAMESPACE_URI, ECHO_RESPONSE_LOCAL_NAME);
+ Text responseText = document.createTextNode(echo);
+ responseElement.appendChild(responseText);
+ return responseElement;
+ }
+}
diff --git a/echo/server/src/main/resources/log4j.properties b/echo/server/src/main/resources/log4j.properties
new file mode 100644
index 0000000..0f73a75
--- /dev/null
+++ b/echo/server/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+log4j.rootLogger=WARN, stdout
+log4j.logger.org.springframework.ws=DEBUG
+log4j.logger.org.springframework.xml=DEBUG
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
\ No newline at end of file
diff --git a/echo/server/src/main/webapp/WEB-INF/echo.xsd b/echo/server/src/main/webapp/WEB-INF/echo.xsd
new file mode 100644
index 0000000..1fac4c1
--- /dev/null
+++ b/echo/server/src/main/webapp/WEB-INF/echo.xsd
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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
new file mode 100755
index 0000000..fd4b06a
--- /dev/null
+++ b/echo/server/src/main/webapp/WEB-INF/spring-ws-servlet.xml
@@ -0,0 +1,40 @@
+
+
+
+
+ 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
new file mode 100755
index 0000000..2c60c8c
--- /dev/null
+++ b/echo/server/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ "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
diff --git a/echo/server/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java b/echo/server/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java
new file mode 100644
index 0000000..6ce3af3
--- /dev/null
+++ b/echo/server/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2005-2010 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.ws;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.springframework.ws.samples.echo.service.EchoService;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+import static org.easymock.EasyMock.*;
+
+public class EchoEndpointTest {
+
+ private EchoEndpoint endpoint;
+
+ private Document requestDocument;
+
+ private Document responseDocument;
+
+ private EchoService mock;
+
+ @Before
+ public void setUp() throws Exception {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ requestDocument = documentBuilder.newDocument();
+ responseDocument = documentBuilder.newDocument();
+ mock = createMock(EchoService.class);
+ endpoint = new EchoEndpoint(mock);
+ }
+
+ @Test
+ public void testInvokeInternal() throws Exception {
+ Element echoRequest =
+ requestDocument.createElementNS(EchoEndpoint.NAMESPACE_URI, EchoEndpoint.ECHO_REQUEST_LOCAL_NAME);
+ String content = "ABC";
+ Text requestText = requestDocument.createTextNode(content);
+ echoRequest.appendChild(requestText);
+ String result = "DEF";
+ expect(mock.echo(content)).andReturn(result);
+
+ replay(mock);
+
+ Element echoResponse = endpoint.handleEchoRequest(echoRequest);
+ Assert.assertEquals("Invalid namespace", EchoEndpoint.NAMESPACE_URI, echoResponse.getNamespaceURI());
+ Assert.assertEquals("Invalid namespace", EchoEndpoint.ECHO_RESPONSE_LOCAL_NAME, echoResponse.getLocalName());
+ Text responseText = (Text) echoResponse.getChildNodes().item(0);
+ Assert.assertEquals("Invalid content", result, responseText.getNodeValue());
+
+ verify(mock);
+ }
+
+}
\ No newline at end of file
diff --git a/echo/server/src/test/resources/log4j.properties b/echo/server/src/test/resources/log4j.properties
new file mode 100644
index 0000000..ad4c9d4
--- /dev/null
+++ b/echo/server/src/test/resources/log4j.properties
@@ -0,0 +1,5 @@
+log4j.rootCategory=WARN, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
diff --git a/echo/settings.gradle b/echo/settings.gradle
new file mode 100644
index 0000000..72c6a98
--- /dev/null
+++ b/echo/settings.gradle
@@ -0,0 +1,2 @@
+
+include "server", "client:saaj", "client:spring-ws"