diff --git a/samples/mtom/client/jaxws/build.xml b/samples/mtom/client/jaxws/build.xml
new file mode 100644
index 00000000..6187e150
--- /dev/null
+++ b/samples/mtom/client/jaxws/build.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/mtom/client/jaxws/readme.txt b/samples/mtom/client/jaxws/readme.txt
new file mode 100644
index 00000000..94586730
--- /dev/null
+++ b/samples/mtom/client/jaxws/readme.txt
@@ -0,0 +1,11 @@
+SPRING WEB SERVICES
+
+This directory contains a Java client for the MTOM Sample that uses JAX-WS.
+The client can be run from the provided ant file, by calling "ant run".
+Note that the airline sample has to be running before invoking this target.
+
+Client Sample table of contents
+---------------------------------------------------
+* src - The source files for the client
+* build.xml - Ant build file with a 'build' and a 'run' target
+
diff --git a/samples/mtom/client/jaxws/spring-ws-logo.png b/samples/mtom/client/jaxws/spring-ws-logo.png
new file mode 100644
index 00000000..2bdbd1a6
Binary files /dev/null and b/samples/mtom/client/jaxws/spring-ws-logo.png differ
diff --git a/samples/mtom/client/jaxws/src/org/springframework/ws/samples/mtom/client/jaxws/Main.java b/samples/mtom/client/jaxws/src/org/springframework/ws/samples/mtom/client/jaxws/Main.java
new file mode 100644
index 00000000..ea4e92dd
--- /dev/null
+++ b/samples/mtom/client/jaxws/src/org/springframework/ws/samples/mtom/client/jaxws/Main.java
@@ -0,0 +1,70 @@
+/*
+ * 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.mtom.client.jaxws;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.net.MalformedURLException;
+import javax.activation.DataHandler;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.springframework.util.StopWatch;
+
+/**
+ * Simple client that calls the GetFlights and BookFlight operations using JAX-WS.
+ *
+ * @author Arjen Poutsma
+ */
+public class Main {
+
+ public static void main(String[] args) throws IOException {
+ try {
+
+ ImageRepositoryService service = new ImageRepositoryService();
+ ImageRepository imageRepository = service.getImageRepositoryPort();
+ SOAPBinding binding = (SOAPBinding)((BindingProvider)imageRepository).getBinding ();
+ binding.setMTOMEnabled (true);
+
+ Image request = new Image();
+ File file = new File(args[0]);
+ request.setName(file.getName());
+ request.setImage(new DataHandler(file.toURL()));
+ StopWatch stopWatch = new StopWatch();
+ stopWatch.start("store");
+ imageRepository.storeImage(request);
+ stopWatch.stop();
+
+ stopWatch.start("load");
+ Image response = imageRepository.loadImage(file.getName());
+ stopWatch.stop();
+ System.out.println(stopWatch.prettyPrint());
+ }
+ catch (SOAPFaultException ex) {
+ System.err.format("SOAP Fault Code %1s%n", ex.getFault().getFaultCodeAsQName());
+ System.err.format("SOAP Fault String: %1s%n", ex.getFault().getFaultString());
+ }
+
+ }
+
+
+}
diff --git a/samples/mtom/pom.xml b/samples/mtom/pom.xml
new file mode 100644
index 00000000..01f5cdd3
--- /dev/null
+++ b/samples/mtom/pom.xml
@@ -0,0 +1,87 @@
+
+
+
+ spring-ws-samples
+ org.springframework.ws
+ 1.0-rc2-SNAPSHOT
+
+ 4.0.0
+ mtom
+ war
+ Spring WS MTOM Example
+ This sample shows how to use MTOM and JAXB2.
+
+
+ java.net
+ Java.net Repository for Maven2
+ http://download.java.net/maven/1/
+ legacy
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.5
+ 1.5
+
+
+
+ com.sun.tools.xjc.maven2
+ maven-jaxb-plugin
+
+
+ generate-sources
+
+ generate
+
+
+
+
+ org.springframework.ws.samples.mtom.schema
+ src/main/webapp/WEB-INF
+
+
+
+
+
+
+
+ org.springframework.ws
+ spring-ws-core-tiger
+
+
+ org.springframework.ws
+ spring-oxm-tiger
+
+
+
+ javax.activation
+ activation
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.1
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.1.3
+ runtime
+
+
+
+ org.springframework
+ spring-mock
+
+
+ easymock
+ easymock
+ 1.2_Java1.3
+ test
+
+
+
diff --git a/samples/mtom/readme.txt b/samples/mtom/readme.txt
new file mode 100644
index 00000000..b7bfc43c
--- /dev/null
+++ b/samples/mtom/readme.txt
@@ -0,0 +1,12 @@
+====================================
+== Spring Web Service MTOM Sample ==
+====================================
+
+
+1. INTRODUCTION
+
+This sample shows how to use marshal and unmarshal MTOM attachments using JAXB2.
+
+2. INSTALLATION
+
+Simply run "mvn package" and deploy the war file generated in target
diff --git a/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/service/ImageRepository.java b/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/service/ImageRepository.java
new file mode 100644
index 00000000..2f9e9c34
--- /dev/null
+++ b/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/service/ImageRepository.java
@@ -0,0 +1,30 @@
+/*
+ * 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.mtom.service;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/** @author Arjen Poutsma */
+public interface ImageRepository {
+
+ void streamImage(String name, OutputStream os) throws IOException;
+
+ void storeImage(String name, InputStream is) throws IOException;
+
+}
diff --git a/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/service/StubImageRepository.java b/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/service/StubImageRepository.java
new file mode 100644
index 00000000..4e9b30ca
--- /dev/null
+++ b/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/service/StubImageRepository.java
@@ -0,0 +1,49 @@
+/*
+ * 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.mtom.service;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.util.FileCopyUtils;
+
+/** @author Arjen Poutsma */
+public class StubImageRepository implements ImageRepository {
+
+ private static final Log logger = LogFactory.getLog(StubImageRepository.class);
+
+ private Map images = new HashMap();
+
+ public void streamImage(String name, OutputStream os) throws IOException {
+ if (images.containsKey(name)) {
+ logger.info("Streaming image " + name);
+ byte[] buf = images.get(name);
+ FileCopyUtils.copy(buf, os);
+ }
+ }
+
+ public void storeImage(String name, InputStream is) throws IOException {
+ byte[] buf = FileCopyUtils.copyToByteArray(is);
+ logger.info("Storing image " + name + " with size: " + buf.length);
+ images.put(name, buf);
+ }
+}
diff --git a/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/ws/ImageRepositoryEndpoint.java b/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/ws/ImageRepositoryEndpoint.java
new file mode 100644
index 00000000..62341084
--- /dev/null
+++ b/samples/mtom/src/main/java/org/springframework/ws/samples/mtom/ws/ImageRepositoryEndpoint.java
@@ -0,0 +1,67 @@
+/*
+ * 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.mtom.ws;
+
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.xml.bind.JAXBElement;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.util.Assert;
+import org.springframework.ws.samples.mtom.schema.Image;
+import org.springframework.ws.samples.mtom.schema.ObjectFactory;
+import org.springframework.ws.samples.mtom.service.ImageRepository;
+import org.springframework.ws.server.endpoint.annotation.Endpoint;
+import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
+
+/** @author Arjen Poutsma */
+@Endpoint
+public class ImageRepositoryEndpoint {
+
+ private ImageRepository imageRepository;
+
+ private ObjectFactory objectFactory;
+
+ public ImageRepositoryEndpoint(ImageRepository imageRepository) {
+ Assert.notNull(imageRepository, "'imageRepository' must not be null");
+ this.imageRepository = imageRepository;
+ this.objectFactory = new ObjectFactory();
+ }
+
+ @PayloadRoot(localPart = "StoreImageRequest", namespace = "http://www.springframework.org/spring-ws/samples/mtom")
+ public void store(JAXBElement requestElement) throws IOException {
+ Image request = requestElement.getValue();
+ imageRepository.storeImage(request.getName(), request.getImage().getInputStream());
+ }
+
+ @PayloadRoot(localPart = "LoadImageRequest", namespace = "http://www.springframework.org/spring-ws/samples/mtom")
+ public JAXBElement load(JAXBElement requestElement) throws IOException {
+ String name = requestElement.getValue();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ imageRepository.streamImage(name, os);
+ DataHandler dataHandler = new DataHandler(os.toByteArray(), "application/octet-stream");
+ Image response = new Image();
+ response.setName(name);
+ response.setImage(dataHandler);
+ return objectFactory.createLoadImageResponse(response);
+ }
+
+}
diff --git a/samples/mtom/src/main/resources/log4j.properties b/samples/mtom/src/main/resources/log4j.properties
new file mode 100644
index 00000000..0f73a758
--- /dev/null
+++ b/samples/mtom/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/samples/mtom/src/main/webapp/WEB-INF/schema.xsd b/samples/mtom/src/main/webapp/WEB-INF/schema.xsd
new file mode 100644
index 00000000..9582b45c
--- /dev/null
+++ b/samples/mtom/src/main/webapp/WEB-INF/schema.xsd
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/mtom/src/main/webapp/WEB-INF/spring-ws-servlet.xml b/samples/mtom/src/main/webapp/WEB-INF/spring-ws-servlet.xml
new file mode 100644
index 00000000..0d0f2e27
--- /dev/null
+++ b/samples/mtom/src/main/webapp/WEB-INF/spring-ws-servlet.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/mtom/src/main/webapp/WEB-INF/web.xml b/samples/mtom/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000..68288e8a
--- /dev/null
+++ b/samples/mtom/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ MyCompany HR Holiday Service
+
+
+ spring-ws
+ org.springframework.ws.transport.http.MessageDispatcherServlet
+
+
+
+ spring-ws
+ /*
+
+
+