You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/15 20:21:33 UTC

svn commit: r1778944 - in /axis/axis2/java/core/trunk/modules/transport: http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/ http/src/org/apache/axis2/transport/http/ http/src/org/apache/axis2/transport/http/impl/httpclient4/

Author: veithen
Date: Sun Jan 15 20:21:32 2017
New Revision: 1778944

URL: http://svn.apache.org/viewvc?rev=1778944&view=rev
Log:
Trivial refactoring to start simplifying/unifying the HTTP transport code.

Added:
    axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/Request.java
Modified:
    axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
    axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java
    axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java

Modified: axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java?rev=1778944&r1=1778943&r2=1778944&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java Sun Jan 15 20:21:32 2017
@@ -46,6 +46,7 @@ import org.apache.axis2.transport.http.H
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPSender;
 import org.apache.axis2.transport.http.HTTPTransportConstants;
+import org.apache.axis2.transport.http.Request;
 import org.apache.axis2.util.MessageProcessorSelector;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.httpclient.Header;
@@ -92,31 +93,35 @@ public class HTTPSenderImpl extends HTTP
      * @throws AxisFault
      *             - Thrown in case an exception occurs
      */
-    protected void sendViaGet(MessageContext msgContext, URL url, String soapActiionString)
+    protected Request prepareGet(final MessageContext msgContext, final URL url, final String soapActiionString)
             throws AxisFault {
-
-        GetMethod getMethod = new GetMethod();
-        HttpClient httpClient = getHttpClient(msgContext);
-        MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, getMethod,
-                httpClient, soapActiionString);
-
-        // Need to have this here because we can have soap action when using the
-        // soap response MEP
-        String soapAction = messageFormatter
-                .formatSOAPAction(msgContext, format, soapActiionString);
-
-        if (soapAction != null && !msgContext.isDoingREST()) {
-            getMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
-        }
-        try {
-            executeMethod(httpClient, msgContext, url, getMethod);
-            handleResponse(msgContext, getMethod);
-        } catch (IOException e) {
-            log.info("Unable to sendViaGet to url[" + url + "]", e);
-            throw AxisFault.makeFault(e);
-        } finally {
-            cleanup(msgContext, getMethod);
-        }
+        return new Request() {
+            @Override
+            public void execute() throws AxisFault {
+                GetMethod getMethod = new GetMethod();
+                HttpClient httpClient = getHttpClient(msgContext);
+                MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, getMethod,
+                        httpClient, soapActiionString);
+        
+                // Need to have this here because we can have soap action when using the
+                // soap response MEP
+                String soapAction = messageFormatter
+                        .formatSOAPAction(msgContext, format, soapActiionString);
+        
+                if (soapAction != null && !msgContext.isDoingREST()) {
+                    getMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
+                }
+                try {
+                    executeMethod(httpClient, msgContext, url, getMethod);
+                    handleResponse(msgContext, getMethod);
+                } catch (IOException e) {
+                    log.info("Unable to sendViaGet to url[" + url + "]", e);
+                    throw AxisFault.makeFault(e);
+                } finally {
+                    cleanup(msgContext, getMethod);
+                }
+            }
+        };
     }
 
     protected void cleanup(MessageContext msgContext, Object httpMmethod) {
@@ -140,22 +145,26 @@ public class HTTPSenderImpl extends HTTP
      * @throws AxisFault
      *             - Thrown in case an exception occurs
      */
-    protected void sendViaDelete(MessageContext msgContext, URL url, String soapActiionString)
+    protected Request prepareDelete(final MessageContext msgContext, final URL url, final String soapActiionString)
             throws AxisFault {
-
-        DeleteMethod deleteMethod = new DeleteMethod();
-        HttpClient httpClient = getHttpClient(msgContext);
-        populateCommonProperties(msgContext, url, deleteMethod, httpClient, soapActiionString);
-
-        try {
-            executeMethod(httpClient, msgContext, url, deleteMethod);
-            handleResponse(msgContext, deleteMethod);
-        } catch (IOException e) {
-            log.info("Unable to sendViaDelete to url[" + url + "]", e);
-            throw AxisFault.makeFault(e);
-        } finally {
-            cleanup(msgContext, deleteMethod);
-        }
+        return new Request() {
+            @Override
+            public void execute() throws AxisFault {
+                DeleteMethod deleteMethod = new DeleteMethod();
+                HttpClient httpClient = getHttpClient(msgContext);
+                populateCommonProperties(msgContext, url, deleteMethod, httpClient, soapActiionString);
+        
+                try {
+                    executeMethod(httpClient, msgContext, url, deleteMethod);
+                    handleResponse(msgContext, deleteMethod);
+                } catch (IOException e) {
+                    log.info("Unable to sendViaDelete to url[" + url + "]", e);
+                    throw AxisFault.makeFault(e);
+                } finally {
+                    cleanup(msgContext, deleteMethod);
+                }
+            }
+        };
     }
 
     /**
@@ -170,53 +179,57 @@ public class HTTPSenderImpl extends HTTP
      * @throws AxisFault
      *             - Thrown in case an exception occurs
      */
-    protected void sendViaPost(MessageContext msgContext, URL url, String soapActionString)
+    protected Request preparePost(final MessageContext msgContext, final URL url, final String soapActionString)
             throws AxisFault {
-
-        HttpClient httpClient = getHttpClient(msgContext);
-
-        /*
-         * What's up with this, it never gets used anywhere?? --Glen String
-         * charEncoding = (String)
-         * msgContext.getProperty(Constants.Configuration
-         * .CHARACTER_SET_ENCODING);
-         * 
-         * if (charEncoding == null) { charEncoding =
-         * MessageContext.DEFAULT_CHAR_SET_ENCODING; }
-         */
-
-        PostMethod postMethod = new PostMethod();
-        if (log.isTraceEnabled()) {
-            log.trace(Thread.currentThread() + " PostMethod " + postMethod + " / " + httpClient);
-        }
-        MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, postMethod,
-                httpClient, soapActionString);
-
-        postMethod.setRequestEntity(new AxisRequestEntityImpl(messageFormatter, msgContext, format,
-                soapActionString, chunked, isAllowedRetry));
-
-        if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chunked) {
-            postMethod.setContentChunked(true);
-        }
-
-        String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
-
-        if (soapAction != null && !msgContext.isDoingREST()) {
-            postMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
-        }
-
-        /*
-         * main excecution takes place..
-         */
-        try {
-            executeMethod(httpClient, msgContext, url, postMethod);
-            handleResponse(msgContext, postMethod);
-        } catch (IOException e) {
-            log.info("Unable to sendViaPost to url[" + url + "]", e);
-            throw AxisFault.makeFault(e);
-        } finally {
-            cleanup(msgContext, postMethod);
-        }
+        return new Request() {
+            @Override
+            public void execute() throws AxisFault {
+                HttpClient httpClient = getHttpClient(msgContext);
+        
+                /*
+                 * What's up with this, it never gets used anywhere?? --Glen String
+                 * charEncoding = (String)
+                 * msgContext.getProperty(Constants.Configuration
+                 * .CHARACTER_SET_ENCODING);
+                 * 
+                 * if (charEncoding == null) { charEncoding =
+                 * MessageContext.DEFAULT_CHAR_SET_ENCODING; }
+                 */
+        
+                PostMethod postMethod = new PostMethod();
+                if (log.isTraceEnabled()) {
+                    log.trace(Thread.currentThread() + " PostMethod " + postMethod + " / " + httpClient);
+                }
+                MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, postMethod,
+                        httpClient, soapActionString);
+        
+                postMethod.setRequestEntity(new AxisRequestEntityImpl(messageFormatter, msgContext, format,
+                        soapActionString, chunked, isAllowedRetry));
+        
+                if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chunked) {
+                    postMethod.setContentChunked(true);
+                }
+        
+                String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
+        
+                if (soapAction != null && !msgContext.isDoingREST()) {
+                    postMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
+                }
+        
+                /*
+                 * main excecution takes place..
+                 */
+                try {
+                    executeMethod(httpClient, msgContext, url, postMethod);
+                    handleResponse(msgContext, postMethod);
+                } catch (IOException e) {
+                    log.info("Unable to sendViaPost to url[" + url + "]", e);
+                    throw AxisFault.makeFault(e);
+                } finally {
+                    cleanup(msgContext, postMethod);
+                }
+            }
+        };
     }
 
     /**
@@ -231,49 +244,53 @@ public class HTTPSenderImpl extends HTTP
      * @throws AxisFault
      *             - Thrown in case an exception occurs
      */
-    protected void sendViaPut(MessageContext msgContext, URL url, String soapActionString)
+    protected Request preparePut(final MessageContext msgContext, final URL url, final String soapActionString)
             throws AxisFault {
-
-        HttpClient httpClient = getHttpClient(msgContext);
-
-        /*
-         * Same deal - this value never gets used, why is it here? --Glen String
-         * charEncoding = (String)
-         * msgContext.getProperty(Constants.Configuration
-         * .CHARACTER_SET_ENCODING);
-         * 
-         * if (charEncoding == null) { charEncoding =
-         * MessageContext.DEFAULT_CHAR_SET_ENCODING; }
-         */
-
-        PutMethod putMethod = new PutMethod();
-        MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, putMethod,
-                httpClient, soapActionString);
-
-        putMethod.setRequestEntity(new AxisRequestEntityImpl(messageFormatter, msgContext, format,
-                soapActionString, chunked, isAllowedRetry));
-
-        if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chunked) {
-            putMethod.setContentChunked(true);
-        }
-
-        String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
-        if (soapAction != null && !msgContext.isDoingREST()) {
-            putMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
-        }
-
-        /*
-         * main excecution takes place..
-         */
-        try {
-            executeMethod(httpClient, msgContext, url, putMethod);
-            handleResponse(msgContext, putMethod);
-        } catch (IOException e) {
-            log.info("Unable to sendViaPut to url[" + url + "]", e);
-            throw AxisFault.makeFault(e);
-        } finally {
-            cleanup(msgContext, putMethod);
-        }
+        return new Request() {
+            @Override
+            public void execute() throws AxisFault {
+                HttpClient httpClient = getHttpClient(msgContext);
+        
+                /*
+                 * Same deal - this value never gets used, why is it here? --Glen String
+                 * charEncoding = (String)
+                 * msgContext.getProperty(Constants.Configuration
+                 * .CHARACTER_SET_ENCODING);
+                 * 
+                 * if (charEncoding == null) { charEncoding =
+                 * MessageContext.DEFAULT_CHAR_SET_ENCODING; }
+                 */
+        
+                PutMethod putMethod = new PutMethod();
+                MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, putMethod,
+                        httpClient, soapActionString);
+        
+                putMethod.setRequestEntity(new AxisRequestEntityImpl(messageFormatter, msgContext, format,
+                        soapActionString, chunked, isAllowedRetry));
+        
+                if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chunked) {
+                    putMethod.setContentChunked(true);
+                }
+        
+                String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
+                if (soapAction != null && !msgContext.isDoingREST()) {
+                    putMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
+                }
+        
+                /*
+                 * main excecution takes place..
+                 */
+                try {
+                    executeMethod(httpClient, msgContext, url, putMethod);
+                    handleResponse(msgContext, putMethod);
+                } catch (IOException e) {
+                    log.info("Unable to sendViaPut to url[" + url + "]", e);
+                    throw AxisFault.makeFault(e);
+                } finally {
+                    cleanup(msgContext, putMethod);
+                }
+            }
+        };
     }
 
     /**

Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java?rev=1778944&r1=1778943&r2=1778944&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java Sun Jan 15 20:21:32 2017
@@ -41,7 +41,7 @@ public abstract class HTTPSender extends
      * @param soapActiionString - The soapAction string of the request
      * @throws AxisFault - Thrown in case an exception occurs
      */
-    protected abstract void sendViaGet(MessageContext msgContext, URL url, String soapActiionString)
+    protected abstract Request prepareGet(MessageContext msgContext, URL url, String soapActiionString)
             throws AxisFault;
     
     /**
@@ -52,7 +52,7 @@ public abstract class HTTPSender extends
      * @param soapActiionString - The soapAction string of the request
      * @throws AxisFault - Thrown in case an exception occurs
      */
-    protected abstract void sendViaDelete(MessageContext msgContext, URL url, String soapActiionString)
+    protected abstract Request prepareDelete(MessageContext msgContext, URL url, String soapActiionString)
             throws AxisFault; 
     /**
      * Used to send a request via HTTP Post Method
@@ -62,7 +62,7 @@ public abstract class HTTPSender extends
      * @param soapActionString - The soapAction string of the request
      * @throws AxisFault - Thrown in case an exception occurs
      */
-    protected abstract void sendViaPost(MessageContext msgContext, URL url,
+    protected abstract Request preparePost(MessageContext msgContext, URL url,
                              String soapActionString) throws AxisFault;
 
 
@@ -74,7 +74,7 @@ public abstract class HTTPSender extends
      * @param soapActionString - The soapAction string of the request
      * @throws AxisFault - Thrown in case an exception occurs
      */
-    protected abstract void sendViaPut(MessageContext msgContext, URL url,
+    protected abstract Request preparePut(MessageContext msgContext, URL url,
                             String soapActionString) throws AxisFault;
 
      
@@ -104,21 +104,21 @@ public abstract class HTTPSender extends
         if ((httpMethod != null)) {
 
             if (Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
-                this.sendViaGet(msgContext, url, soapActionString);
+                this.prepareGet(msgContext, url, soapActionString).execute();;
 
                 return;
             } else if (Constants.Configuration.HTTP_METHOD_DELETE.equalsIgnoreCase(httpMethod)) {
-                this.sendViaDelete(msgContext, url, soapActionString);
+                this.prepareDelete(msgContext, url, soapActionString).execute();
 
                 return;
             } else if (Constants.Configuration.HTTP_METHOD_PUT.equalsIgnoreCase(httpMethod)) {
-                this.sendViaPut(msgContext, url, soapActionString);
+                this.preparePut(msgContext, url, soapActionString).execute();
 
                 return;
             }
         }
 
-        this.sendViaPost(msgContext, url, soapActionString);
+        this.preparePost(msgContext, url, soapActionString).execute();
     }   
 
     /**

Added: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/Request.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/Request.java?rev=1778944&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/Request.java (added)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/Request.java Sun Jan 15 20:21:32 2017
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.axis2.transport.http;
+
+import org.apache.axis2.AxisFault;
+
+/**
+ * Interface to prepare and execute an HTTP request.
+ */
+public interface Request {
+    void execute() throws AxisFault;
+}

Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java?rev=1778944&r1=1778943&r2=1778944&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java Sun Jan 15 20:21:32 2017
@@ -34,6 +34,7 @@ import org.apache.axis2.transport.http.H
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPSender;
 import org.apache.axis2.transport.http.HTTPTransportConstants;
+import org.apache.axis2.transport.http.Request;
 import org.apache.axis2.util.MessageProcessorSelector;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
@@ -103,35 +104,40 @@ public class HTTPSenderImpl extends HTTP
      * @param soapActionString - The soapAction string of the request
      * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
      */
-    protected void sendViaGet(MessageContext msgContext, URL url, String soapActionString)
+    protected Request prepareGet(final MessageContext msgContext, final URL url, final String soapActionString)
             throws AxisFault {
-        HttpGet httpGet = new HttpGet();
-        AbstractHttpClient httpClient = getHttpClient(msgContext);
-        MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, httpGet,
-                                                                     httpClient, soapActionString);
-
-        // Need to have this here because we can have soap action when using the
-        // soap response MEP
-        String soapAction = messageFormatter
-                .formatSOAPAction(msgContext, format, soapActionString);
-
-        if (soapAction != null && !msgContext.isDoingREST()) {
-            httpGet.setHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
-        }
-
-        /*
-         * main execution takes place..
-         */
-        HttpResponse response = null;
-        try {
-            response = executeMethod(httpClient, msgContext, url, httpGet);
-            handleResponse(msgContext, response);
-        } catch (IOException e) {
-            log.info("Unable to sendViaGet to url[" + url + "]", e);
-            throw AxisFault.makeFault(e);
-        } finally {
-            cleanup(msgContext, response);
-        }
+        return new Request() {
+            @Override
+            public void execute() throws AxisFault {
+                HttpGet httpGet = new HttpGet();
+                AbstractHttpClient httpClient = getHttpClient(msgContext);
+                MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, httpGet,
+                                                                             httpClient, soapActionString);
+        
+                // Need to have this here because we can have soap action when using the
+                // soap response MEP
+                String soapAction = messageFormatter
+                        .formatSOAPAction(msgContext, format, soapActionString);
+        
+                if (soapAction != null && !msgContext.isDoingREST()) {
+                    httpGet.setHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
+                }
+        
+                /*
+                 * main execution takes place..
+                 */
+                HttpResponse response = null;
+                try {
+                    response = executeMethod(httpClient, msgContext, url, httpGet);
+                    handleResponse(msgContext, response);
+                } catch (IOException e) {
+                    log.info("Unable to sendViaGet to url[" + url + "]", e);
+                    throw AxisFault.makeFault(e);
+                } finally {
+                    cleanup(msgContext, response);
+                }
+            }
+        };
     }
 
     @Override
@@ -164,26 +170,30 @@ public class HTTPSenderImpl extends HTTP
      * @param soapActionString - The soapAction string of the request
      * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
      */
-    protected void sendViaDelete(MessageContext msgContext, URL url, String soapActionString)
+    protected Request prepareDelete(final MessageContext msgContext, final URL url, final String soapActionString)
             throws AxisFault {
-
-        HttpDelete deleteMethod = new HttpDelete();
-        AbstractHttpClient httpClient = getHttpClient(msgContext);
-        populateCommonProperties(msgContext, url, deleteMethod, httpClient, soapActionString);
-
-        /*
-         * main execution takes place..
-         */
-        HttpResponse response = null;
-        try {
-            response = executeMethod(httpClient, msgContext, url, deleteMethod);
-            handleResponse(msgContext, response);
-        } catch (IOException e) {
-            log.info("Unable to sendViaDelete to url[" + url + "]", e);
-            throw AxisFault.makeFault(e);
-        } finally {
-            cleanup(msgContext, response);
-        }
+        return new Request() {
+            @Override
+            public void execute() throws AxisFault {
+                HttpDelete deleteMethod = new HttpDelete();
+                AbstractHttpClient httpClient = getHttpClient(msgContext);
+                populateCommonProperties(msgContext, url, deleteMethod, httpClient, soapActionString);
+        
+                /*
+                 * main execution takes place..
+                 */
+                HttpResponse response = null;
+                try {
+                    response = executeMethod(httpClient, msgContext, url, deleteMethod);
+                    handleResponse(msgContext, response);
+                } catch (IOException e) {
+                    log.info("Unable to sendViaDelete to url[" + url + "]", e);
+                    throw AxisFault.makeFault(e);
+                } finally {
+                    cleanup(msgContext, response);
+                }
+            }
+        };
     }
 
     /**
@@ -194,55 +204,59 @@ public class HTTPSenderImpl extends HTTP
      * @param soapActionString - The soapAction string of the request
      * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
      */
-    protected void sendViaPost(MessageContext msgContext, URL url, String soapActionString)
+    protected Request preparePost(final MessageContext msgContext, final URL url, final String soapActionString)
             throws AxisFault {
-
-        AbstractHttpClient httpClient = getHttpClient(msgContext);
-
-        /*
-         * What's up with this, it never gets used anywhere?? --Glen String
-         * charEncoding = (String)
-         * msgContext.getProperty(Constants.Configuration
-         * .CHARACTER_SET_ENCODING);
-         *
-         * if (charEncoding == null) { charEncoding =
-         * MessageContext.DEFAULT_CHAR_SET_ENCODING; }
-         */
-
-        HttpPost postMethod = new HttpPost();
-        if (log.isTraceEnabled()) {
-            log.trace(Thread.currentThread() + " PostMethod " + postMethod + " / " + httpClient);
-        }
-        MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, postMethod,
-                                                                     httpClient, soapActionString);
-        AxisRequestEntityImpl requestEntity =
-                new AxisRequestEntityImpl(messageFormatter, msgContext, format,
-                                          soapActionString, chunked, isAllowedRetry);
-        postMethod.setEntity(requestEntity);
-
-        if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chunked) {
-            requestEntity.setChunked(chunked);
-        }
-
-        String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
-
-        if (soapAction != null && !msgContext.isDoingREST()) {
-            postMethod.setHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
-        }
-
-        /*
-         * main execution takes place..
-         */
-        HttpResponse response = null;
-        try {
-            response = executeMethod(httpClient, msgContext, url, postMethod);
-            handleResponse(msgContext, response);
-        } catch (IOException e) {
-            log.info("Unable to sendViaPost to url[" + url + "]", e);
-            throw AxisFault.makeFault(e);
-        } finally {
-            cleanup(msgContext, response);
-        }
+        return new Request() {
+            @Override
+            public void execute() throws AxisFault {
+                AbstractHttpClient httpClient = getHttpClient(msgContext);
+        
+                /*
+                 * What's up with this, it never gets used anywhere?? --Glen String
+                 * charEncoding = (String)
+                 * msgContext.getProperty(Constants.Configuration
+                 * .CHARACTER_SET_ENCODING);
+                 *
+                 * if (charEncoding == null) { charEncoding =
+                 * MessageContext.DEFAULT_CHAR_SET_ENCODING; }
+                 */
+        
+                HttpPost postMethod = new HttpPost();
+                if (log.isTraceEnabled()) {
+                    log.trace(Thread.currentThread() + " PostMethod " + postMethod + " / " + httpClient);
+                }
+                MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, postMethod,
+                                                                             httpClient, soapActionString);
+                AxisRequestEntityImpl requestEntity =
+                        new AxisRequestEntityImpl(messageFormatter, msgContext, format,
+                                                  soapActionString, chunked, isAllowedRetry);
+                postMethod.setEntity(requestEntity);
+        
+                if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chunked) {
+                    requestEntity.setChunked(chunked);
+                }
+        
+                String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
+        
+                if (soapAction != null && !msgContext.isDoingREST()) {
+                    postMethod.setHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
+                }
+        
+                /*
+                 * main execution takes place..
+                 */
+                HttpResponse response = null;
+                try {
+                    response = executeMethod(httpClient, msgContext, url, postMethod);
+                    handleResponse(msgContext, response);
+                } catch (IOException e) {
+                    log.info("Unable to sendViaPost to url[" + url + "]", e);
+                    throw AxisFault.makeFault(e);
+                } finally {
+                    cleanup(msgContext, response);
+                }
+            }
+        };
     }
 
     /**
@@ -253,51 +267,55 @@ public class HTTPSenderImpl extends HTTP
      * @param soapActionString - The soapAction string of the request
      * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
      */
-    protected void sendViaPut(MessageContext msgContext, URL url, String soapActionString)
+    protected Request preparePut(final MessageContext msgContext, final URL url, final String soapActionString)
             throws AxisFault {
-
-        AbstractHttpClient httpClient = getHttpClient(msgContext);
-
-        /*
-         * Same deal - this value never gets used, why is it here? --Glen String
-         * charEncoding = (String)
-         * msgContext.getProperty(Constants.Configuration
-         * .CHARACTER_SET_ENCODING);
-         *
-         * if (charEncoding == null) { charEncoding =
-         * MessageContext.DEFAULT_CHAR_SET_ENCODING; }
-         */
-
-        HttpPut putMethod = new HttpPut();
-        MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, putMethod,
-                                                                     httpClient, soapActionString);
-        AxisRequestEntityImpl requestEntity =
-                new AxisRequestEntityImpl(messageFormatter, msgContext, format,
-                                          soapActionString, chunked, isAllowedRetry);
-        putMethod.setEntity(requestEntity);
-
-        if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chunked) {
-            requestEntity.setChunked(chunked);
-        }
-
-        String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
-        if (soapAction != null && !msgContext.isDoingREST()) {
-            putMethod.setHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
-        }
-
-        /*
-         * main execution takes place..
-         */
-        HttpResponse response = null;
-        try {
-            response = executeMethod(httpClient, msgContext, url, putMethod);
-            handleResponse(msgContext, response);
-        } catch (IOException e) {
-            log.info("Unable to sendViaPut to url[" + url + "]", e);
-            throw AxisFault.makeFault(e);
-        } finally {
-            cleanup(msgContext, response);
-        }
+        return new Request() {
+            @Override
+            public void execute() throws AxisFault {
+                AbstractHttpClient httpClient = getHttpClient(msgContext);
+        
+                /*
+                 * Same deal - this value never gets used, why is it here? --Glen String
+                 * charEncoding = (String)
+                 * msgContext.getProperty(Constants.Configuration
+                 * .CHARACTER_SET_ENCODING);
+                 *
+                 * if (charEncoding == null) { charEncoding =
+                 * MessageContext.DEFAULT_CHAR_SET_ENCODING; }
+                 */
+        
+                HttpPut putMethod = new HttpPut();
+                MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, putMethod,
+                                                                             httpClient, soapActionString);
+                AxisRequestEntityImpl requestEntity =
+                        new AxisRequestEntityImpl(messageFormatter, msgContext, format,
+                                                  soapActionString, chunked, isAllowedRetry);
+                putMethod.setEntity(requestEntity);
+        
+                if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chunked) {
+                    requestEntity.setChunked(chunked);
+                }
+        
+                String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
+                if (soapAction != null && !msgContext.isDoingREST()) {
+                    putMethod.setHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
+                }
+        
+                /*
+                 * main execution takes place..
+                 */
+                HttpResponse response = null;
+                try {
+                    response = executeMethod(httpClient, msgContext, url, putMethod);
+                    handleResponse(msgContext, response);
+                } catch (IOException e) {
+                    log.info("Unable to sendViaPut to url[" + url + "]", e);
+                    throw AxisFault.makeFault(e);
+                } finally {
+                    cleanup(msgContext, response);
+                }
+            }
+        };
     }
 
     /**