diff --git a/core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java b/core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java
index eb7f1ccb..932f4198 100644
--- a/core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java
+++ b/core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java
@@ -413,9 +413,8 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
return handleFault(connection, request, response);
}
else {
- Object extracted = responseExtractor.extractData(response);
logResponse(request, response);
- return extracted;
+ return responseExtractor.extractData(response);
}
}
else {
diff --git a/core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java b/core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java
index 8afb2ab4..75736128 100644
--- a/core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java
+++ b/core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java
@@ -47,6 +47,25 @@ public abstract class AbstractReceiverConnection extends AbstractWebServiceConne
return responseOutputStream;
}
+ public final void close() throws IOException {
+ try {
+ if (requestInputStream != null) {
+ requestInputStream.close();
+ }
+ }
+ finally {
+ onClose();
+ }
+ }
+
+ /**
+ * Template method invoked from {@link #close()}. Default implementation is empty.
+ *
+ * @throws IOException if an I/O error occurs when closing this connection
+ */
+ protected void onClose() throws IOException {
+ }
+
/**
* Returns an iteration over all the header names this request contains. Returns an empty Iterator if
* there areno headers.
@@ -89,6 +108,11 @@ public abstract class AbstractReceiverConnection extends AbstractWebServiceConne
return getRequestHeaders(name);
}
+ public void close() throws IOException {
+ // defer close, some SoapMessage implementations (Axis) lazy-initialize the SOAPMessage
+ }
+
+
}
/** Implementation of TransportOutputStream for sending-side connections. */
diff --git a/core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java b/core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java
index 8a4dabbe..76ef7fb8 100644
--- a/core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java
+++ b/core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java
@@ -52,6 +52,25 @@ public abstract class AbstractSenderConnection extends AbstractWebServiceConnect
}
}
+ public final void close() throws IOException {
+ try {
+ if (responseInputStream != null) {
+ responseInputStream.close();
+ }
+ }
+ finally {
+ onClose();
+ }
+ }
+
+ /**
+ * Template method invoked from {@link #close()}. Default implementation is empty.
+ *
+ * @throws IOException if an I/O error occurs when closing this connection
+ */
+ protected void onClose() throws IOException {
+ }
+
/** Indicates whether this connection has a response. */
protected abstract boolean hasResponse() throws IOException;
@@ -109,6 +128,10 @@ public abstract class AbstractSenderConnection extends AbstractWebServiceConnect
return getResponseHeaders(name);
}
+ public void close() throws IOException {
+ // defer close, some SoapMessage implementations (Axis) lazy-initialize the SOAPMessage
+ }
+
}
}
diff --git a/core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java b/core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java
index 82ba9080..8d144b14 100644
--- a/core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java
+++ b/core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java
@@ -27,6 +27,7 @@ import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
+
import org.springframework.util.Assert;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.transport.WebServiceConnection;
@@ -57,7 +58,7 @@ public class CommonsHttpConnection extends AbstractHttpSenderConnection {
return postMethod;
}
- public void close() throws IOException {
+ public void onClose() throws IOException {
postMethod.releaseConnection();
}
diff --git a/core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java b/core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java
index 4f948950..1f381f65 100644
--- a/core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java
+++ b/core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java
@@ -16,7 +16,6 @@
package org.springframework.ws.transport.http;
-import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -91,12 +90,7 @@ public class HttpServletConnection extends AbstractReceiverConnection
}
protected InputStream getRequestInputStream() throws IOException {
- return new FilterInputStream(getHttpServletRequest().getInputStream()) {
-
- public void close() throws IOException {
- // defer close, some SAAJ implementations (Axis 1) lazy-initialize the SOAPMessage
- }
- };
+ return getHttpServletRequest().getInputStream();
}
/*
@@ -115,7 +109,7 @@ public class HttpServletConnection extends AbstractReceiverConnection
statusCodeSet = true;
}
- public void close() throws IOException {
+ public void onClose() throws IOException {
if (!statusCodeSet) {
getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_ACCEPTED);
}
diff --git a/core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java b/core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java
index 80671fbe..202e0b5b 100644
--- a/core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java
+++ b/core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java
@@ -55,7 +55,7 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection {
return connection;
}
- public void close() {
+ public void onClose() {
connection.disconnect();
}