SWS-245, for real this time, in 1.0 branch

This commit is contained in:
Arjen Poutsma
2007-12-06 20:00:32 +00:00
parent e2e95b19ea
commit ba6d9e736e
6 changed files with 53 additions and 12 deletions

View File

@@ -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 {

View File

@@ -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 <code>Iterator</code> 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 <code>TransportOutputStream</code> for sending-side connections. */

View File

@@ -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
}
}
}

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -55,7 +55,7 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection {
return connection;
}
public void close() {
public void onClose() {
connection.disconnect();
}