You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2005/12/11 00:28:50 UTC

svn commit: r355804 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: context/ transport/http/

Author: ajith
Date: Sat Dec 10 15:28:41 2005
New Revision: 355804

URL: http://svn.apache.org/viewcvs?rev=355804&view=rev
Log:
Adding the HTTP sender change initiated by Thilini. The following changes are the important ones
1. The REST and the SOAP sending functions are pushed into RESTSender.java and SOAPSender.java respectively.
2. To share the functionality, AbstractSender.java class is also introduced.
3. Slight changes are made to contants,TransportUtils and MessageContext

The build passes.

Added:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPSender.java
Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java?rev=355804&r1=355803&r2=355804&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java Sat Dec 10 15:28:41 2005
@@ -829,11 +829,11 @@
         doingREST = b;
     }
 
-    public void setRestThroughPOST(boolean b) {
+    public void setDoingHttpPOST(boolean b) {
         doRESTthroughPOST = b;
     }
 
-    public boolean isRestThroughPOST() {
+    public boolean isDoingHttpPOST() {
         return doRESTthroughPOST;
     }
 

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractSender.java?rev=355804&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractSender.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractSender.java Sat Dec 10 15:28:41 2005
@@ -0,0 +1,417 @@
+/*
+ * Created on Nov 28, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis2.transport.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMOutputFormat;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HeaderElement;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.NTCredentials;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public abstract class AbstractSender {
+	protected boolean chuncked = false;
+
+	protected String httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
+
+	protected Log log = LogFactory.getLog(getClass().getName());
+
+	protected HttpClient httpClient;
+
+	int soTimeout = HTTPConstants.DEFAULT_SO_TIMEOUT;
+
+	int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
+
+	protected static final String ANONYMOUS = "anonymous";
+
+	protected OMOutputFormat format = new OMOutputFormat();
+
+	/**
+	 * proxydiscription
+	 */
+	protected TransportOutDescription proxyOutSetting = null;
+
+	protected static final String PROXY_HOST_NAME = "proxy_host";
+
+	protected static final String PROXY_PORT = "proxy_port";
+
+    public void setFormat(OMOutputFormat format) {
+        this.format = format;
+    }
+
+    public abstract void transportConfiguration(MessageContext msgContext,
+			OMElement dataout, URL url, String soapActionString)
+			throws MalformedURLException, AxisFault, IOException;
+
+	/**
+	 * This is used to get the dynamically set time out values from the
+	 * message context. If the values are not available or invalid then
+	 * teh default values or the values set by teh configuration will be used
+	 *
+	 * @param msgContext
+	 */
+	protected void getTimeoutValues(MessageContext msgContext) {
+		try {
+			// If the SO_TIMEOUT of CONNECTION_TIMEOUT is set by dynamically the
+			// override the static config
+			Integer tempSoTimeoutProperty = (Integer) msgContext
+					.getProperty(HTTPConstants.SO_TIMEOUT);
+			Integer tempConnTimeoutProperty = (Integer) msgContext
+					.getProperty(HTTPConstants.CONNECTION_TIMEOUT);
+
+			if (tempSoTimeoutProperty != null) {
+				soTimeout = tempSoTimeoutProperty.intValue();
+			}
+
+			if (tempConnTimeoutProperty != null) {
+				connectionTimeout = tempConnTimeoutProperty.intValue();
+			}
+		} catch (NumberFormatException nfe) {
+			//If there's a problem log it and use the default values
+			log.error("Invalid timeout value format: not a number", nfe);
+		}
+	}
+
+	/**
+	 * getting host configuration to support standard http/s, proxy and NTLM support
+	 */
+	protected HostConfiguration getHostConfiguration(HttpClient client,
+			MessageContext msgCtx, URL targetURL) throws AxisFault {
+		boolean isHostProxy = isProxyListed(msgCtx); //list the proxy
+		int port = targetURL.getPort();
+		if (port == -1)
+			port = 80;
+		// to see the host is a proxy and in the proxy list - available in axis2.xml
+		HostConfiguration config = new HostConfiguration();
+
+		if (!isHostProxy) {
+			config.setHost(targetURL.getHost(), port, targetURL.getProtocol());
+		} else {
+			//proxy and NTLM configuration
+			this.configProxyAuthentication(client, proxyOutSetting, config,
+					msgCtx);
+		}
+		return config;
+	}
+
+	/**
+	 * Helper method to Proxy and NTLM authentication
+	 *
+	 * @param client
+	 * @param proxySetting
+	 * @param config
+	 */
+
+	protected void configProxyAuthentication(HttpClient client,
+			TransportOutDescription proxySetting, HostConfiguration config,
+			MessageContext msgCtx) throws AxisFault {
+		Parameter proxyParam = proxySetting.getParameter(HTTPConstants.PROXY);
+		String value = (String) proxyParam.getValue();
+		String split[] = value.split(":");
+        
+        //values being hard coded due best practise
+		String usrName = split[0];
+		String domain = split[1];
+		String passwd = split[2];
+		//
+		Credentials proxyCred ;
+
+		String proxyHostName = null;
+		int proxyPort = -1;
+
+		if (proxyParam != null) {
+			OMElement proxyParamElement = proxyParam.getParameterElement();
+			Iterator ite = proxyParamElement.getAllAttributes();
+			while (ite.hasNext()) {
+				OMAttribute att = (OMAttribute) ite.next();
+				if (att.getLocalName().equalsIgnoreCase(PROXY_HOST_NAME)) {
+					proxyHostName = att.getAttributeValue();
+				}
+				if (att.getLocalName().equalsIgnoreCase(PROXY_PORT)) {
+					proxyPort = Integer.parseInt(att.getAttributeValue());
+				}
+			}
+		}
+
+		if (domain.equals("") || domain.equals(ANONYMOUS)) {
+			if (usrName.equals(ANONYMOUS) && passwd.equals(ANONYMOUS)) {
+				proxyCred = new UsernamePasswordCredentials("", "");
+			} else {
+				proxyCred = new UsernamePasswordCredentials(usrName, passwd); //proxy
+			}
+		} else {
+			proxyCred = new NTCredentials(usrName, passwd, proxyHostName,
+					domain); //NTLM authentication with additionals prams
+		}
+
+		HttpTransportProperties.ProxyProperties proxyProperties = (HttpTransportProperties.ProxyProperties) msgCtx
+				.getProperty(HTTPConstants.PROXY);
+		if (proxyProperties != null) {
+			if (proxyProperties.getProxyPort() != -1) {
+				proxyPort = proxyProperties.getProxyPort();
+			}
+			if (proxyProperties.getProxyHostName().equals("")
+					|| proxyProperties.getProxyHostName() != null) {
+				proxyHostName = proxyProperties.getProxyHostName();
+			} else {
+				throw new AxisFault("Proxy Name is not valied");
+			}
+			if (proxyProperties.getUserName().equals(ANONYMOUS)
+					|| proxyProperties.getPassWord().equals(ANONYMOUS)) {
+				proxyCred = new UsernamePasswordCredentials("", "");
+			}
+		}
+		client.getState().setProxyCredentials(AuthScope.ANY, proxyCred);
+		config.setProxy(proxyHostName, proxyPort);
+	}
+
+	private boolean isProxyListed(MessageContext msgCtx) throws AxisFault {
+		boolean returnValue = false;
+		Parameter par = null;
+		proxyOutSetting = msgCtx.getConfigurationContext().getAxisConfiguration()
+				.getTransportOut(new QName(Constants.TRANSPORT_HTTP));
+		if (proxyOutSetting != null) {
+			par = proxyOutSetting.getParameter(HTTPConstants.PROXY);
+		}
+		OMElement hostElement;
+		if (par != null) {
+			hostElement = par.getParameterElement();
+		} else {
+			return returnValue;
+		}
+
+		if (hostElement != null) {
+			Iterator ite = hostElement.getAllAttributes();
+			while (ite.hasNext()) {
+				OMAttribute attribute = (OMAttribute) ite.next();
+				if (attribute.getLocalName().equalsIgnoreCase(PROXY_HOST_NAME)) {
+					returnValue = true;
+				}
+			}
+		}
+
+        HttpTransportProperties.ProxyProperties proxyProperties;
+		if ((proxyProperties = (HttpTransportProperties.ProxyProperties) msgCtx
+				.getProperty(HTTPConstants.PROXY)) != null) {
+			if (proxyProperties.getProxyHostName() != null) {
+				returnValue = true;
+			}
+		}
+		return returnValue;
+	}
+
+	/**
+	 * Collect the HTTP header information and set them in the message context
+	 *
+	 * @param method
+	 * @param msgContext
+	 */
+	protected void obatainHTTPHeaderInformation(HttpMethodBase method,
+			MessageContext msgContext) {
+		Header header = method
+				.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
+		if (header != null) {
+			HeaderElement[] headers = header.getElements();
+			for (int i = 0; i < headers.length; i++) {
+				NameValuePair charsetEnc = headers[i]
+						.getParameterByName(HTTPConstants.CHAR_SET_ENCODING);
+				if (headers[i].getName().equalsIgnoreCase(
+						HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)) {
+					OperationContext opContext = msgContext
+							.getOperationContext();
+					if (opContext != null) {
+						opContext.setProperty(
+								HTTPConstants.MTOM_RECIVED_CONTENT_TYPE, header
+										.getValue());
+					}
+				} else if (charsetEnc != null) {
+
+					msgContext.setProperty(
+							MessageContext.CHARACTER_SET_ENCODING, charsetEnc
+									.getValue()); //change to the value, which is text/xml or application/xml+soap
+				}
+			}
+		}
+	}
+
+	protected void processResponse(HttpMethodBase httpMethod,
+			MessageContext msgContext) throws IOException {
+		obatainHTTPHeaderInformation(httpMethod, msgContext);
+		InputStream in = httpMethod.getResponseBodyAsStream();
+		if (in == null) {
+			throw new AxisFault(Messages.getMessage("canNotBeNull",
+					"InputStream"));
+		}
+		msgContext.getOperationContext().setProperty(
+				MessageContext.TRANSPORT_IN, in);
+	}
+
+	public class AxisRequestEntity implements RequestEntity {
+
+		private String charSetEnc;
+
+		private OMElement element;
+
+		private boolean chuncked;
+
+		private byte[] bytes;
+
+		private boolean doingMTOM = false;
+
+		private String soapActionString;
+
+		private MessageContext msgCtxt;
+
+		public AxisRequestEntity(OMElement element, boolean chuncked,
+				MessageContext msgCtxt, String charSetEncoding,
+				String soapActionString) {
+			this.element = element;
+			this.chuncked = chuncked;
+			this.msgCtxt = msgCtxt;
+			this.doingMTOM = msgCtxt.isDoingMTOM();
+			this.charSetEnc = charSetEncoding;
+			this.soapActionString = soapActionString;
+		}
+
+		public boolean isRepeatable() {
+			return true;
+		}
+
+		public byte[] writeBytes() throws AxisFault {
+			try {
+				ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+
+				if (!doingMTOM) {
+					OMOutputFormat format2 = new OMOutputFormat();
+                    format2.setCharSetEncoding(charSetEnc);
+                    element.serializeAndConsume(bytesOut, format2);
+                    return bytesOut.toByteArray();
+
+				} else {
+					format.setCharSetEncoding(charSetEnc);
+                    format.setDoOptimize(true);
+                    element.serializeAndConsume(bytesOut, format);
+                    return bytesOut.toByteArray();
+				}
+			} catch (XMLStreamException e) {
+				throw new AxisFault(e);
+			} catch (FactoryConfigurationError e) {
+				throw new AxisFault(e);
+			}
+		}
+
+		private void handleOMOutput(OutputStream out, boolean doingMTOM)
+				throws XMLStreamException {
+			format.setDoOptimize(doingMTOM);
+            element.serializeAndConsume(out, format);
+		}
+
+		public void writeRequest(OutputStream out) throws IOException {
+			try {
+				if (doingMTOM) { //chagened ..
+					if (chuncked) {
+						this.handleOMOutput(out, doingMTOM);
+					} else {
+						if (bytes == null) {
+							bytes = writeBytes();
+						}
+						out.write(bytes);
+					}
+
+				} else {
+					if (chuncked) {
+						this.handleOMOutput(out, doingMTOM);
+					} else {
+						if (bytes == null) {
+							bytes = writeBytes();
+						}
+						out.write(bytes);
+					}
+				}
+				out.flush();
+			} catch (XMLStreamException e) {
+				throw new AxisFault(e);
+			} catch (FactoryConfigurationError e) {
+				throw new AxisFault(e);
+			} catch (IOException e) {
+				throw new AxisFault(e);
+			}
+		}
+
+		public long getContentLength() {
+			try {
+				if (doingMTOM) { //chagened
+					if (chuncked) {
+						return -1;
+					} else {
+						if (bytes == null) {
+							bytes = writeBytes();
+						}
+						return bytes.length;
+					}
+				} else {
+					if (chuncked) {
+						return -1;
+					} else {
+						if (bytes == null) {
+							bytes = writeBytes();
+						}
+						return bytes.length;
+					}
+				}
+			} catch (AxisFault e) {
+				return -1;
+			}
+		}
+
+		public String getContentType() {
+			String encoding = format.getCharSetEncoding();
+            String contentType = format.getContentType();
+			if (encoding != null) {
+				contentType += "; charset=" + encoding;
+			}
+
+			// action header is not mandated in SOAP 1.2. So putting it, if available
+			if (!msgCtxt.isSOAP11() && soapActionString != null
+					&& !"".equals(soapActionString.trim())) {
+				contentType = contentType + ";action=\"" + soapActionString
+						+ "\";";
+			}
+			return contentType;
+		}
+	}
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=355804&r1=355803&r2=355804&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Sat Dec 10 15:28:41 2005
@@ -1,17 +1,17 @@
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
- * 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
+ * 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
+ * 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.
+ * 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;
@@ -27,61 +27,33 @@
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMAttribute;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMOutputFormat;
 import org.apache.axis2.om.impl.OMNodeEx;
-import org.apache.axis2.soap.SOAP11Constants;
-import org.apache.axis2.soap.SOAP12Constants;
 import org.apache.axis2.transport.TransportSender;
 import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HeaderElement;
-import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.xml.namespace.QName;
 import javax.xml.stream.FactoryConfigurationError;
 import javax.xml.stream.XMLStreamException;
-import java.io.ByteArrayOutputStream;
+
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
 
-public class CommonsHTTPTransportSender
-        extends AbstractHandler
-        implements TransportSender {
+public class CommonsHTTPTransportSender extends AbstractHandler implements
+        TransportSender {
     private boolean chuncked = false;
 
-    private String httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
-
     int soTimeout = HTTPConstants.DEFAULT_SO_TIMEOUT;
 
     int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
 
-    public static final String HTTP_METHOD = "HTTP_METHOD";
-
     protected HttpClient httpClient;
 
     protected OMElement outputMessage;
@@ -94,79 +66,20 @@
     protected TransportOutDescription proxyOutSetting = null;
 
     protected static final String PROXY_HOST_NAME = "proxy_host";
+
     protected static final String PROXY_PORT = "proxy_port";
 
+    protected String httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
 
     protected Log log = LogFactory.getLog(getClass().getName());
 
-    /**
-     * {@value}
-     */
     private static final String ANONYMOUS = "anonymous";
 
+    public static final String HTTP_METHOD = "HTTP_METHOD";
+
     public CommonsHTTPTransportSender() {
     } //default
 
-    public RequestData createRequest(MessageContext msgContext) {
-        //This used to obtain two strings to go with the url and to pass in the body when doing
-        //POST with application/x-www-form-urlencoded
-        RequestData data = new RequestData();
-        String contentType = findContentType(true, msgContext);
-        OMElement dataOut = msgContext.getEnvelope().getBody().getFirstElement();
-
-        Iterator iter1 = dataOut.getChildElements();
-        ArrayList paraList = new ArrayList();
-        ArrayList urlList = new ArrayList();
-
-        //TODO: s is ALWAYS EMPTY. so what gets added to urllist????
-        String[] s = new String[]{};
-        OMElement bodypara = OMAbstractFactory.getOMFactory().createOMElement("dummy", null);
-
-        while (iter1.hasNext()) {
-            OMElement ele = (OMElement) iter1.next();
-            boolean has = false;
-
-            for (int i = 0; i < s.length; i++) {
-                if (s[i].equals(ele.getLocalName())) {
-                    has = true;
-                    break;
-                }
-            }
-            String parameter1;
-
-            if (has) {
-                parameter1 = ele.getLocalName() + "=" + ele.getText();
-                urlList.add(parameter1);
-
-            } else {
-                bodypara.addChild(ele);
-            }
-        }
-
-        String urlString = "";
-        for (int i = 0; i < urlList.size(); i++) {
-            String c = (String) urlList.get(i);
-            urlString = urlString + "&" + c;
-            data.urlRequest = urlString;
-        }
-
-        Iterator it = bodypara.getChildElements();
-        while (it.hasNext()) {
-            OMElement ele1 = (OMElement) it.next();
-            String parameter2;
-            parameter2 = ele1.getLocalName() + "=" + ele1.getText();
-            paraList.add(parameter2);
-        }
-
-        String paraString = "";
-        for (int j = 0; j < paraList.size(); j++) {
-            String b = (String) paraList.get(j);
-            paraString = paraString + "&" + b;
-            data.bodyRequest = paraString;
-        }
-        return data;
-    }
-
     public synchronized void invoke(MessageContext msgContext) throws AxisFault {
         try {
             String charSetEnc =
@@ -187,12 +100,14 @@
                 charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
             }
             msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+            msgContext.setDoingREST(HTTPTransportUtils.isDoingREST(msgContext));
             format.setSOAP11(msgContext.isSOAP11());
             format.setDoOptimize(msgContext.isDoingMTOM());
 
             format.setCharSetEncoding(charSetEnc);
 
-            // Trasnport URL can be different from the WSA-To. So processing that now.
+            // Trasnport URL can be different from the WSA-To. So processing
+            // that now.
             EndpointReference epr = null;
             String transportURL = (String) msgContext.getProperty(MessageContextConstants.TRANSPORT_URL);
             if (transportURL != null) {
@@ -219,11 +134,7 @@
             /**
              * Figuringout the REST properties/parameters
              */
-            msgContext.setDoingREST(HTTPTransportUtils.isDoingREST(msgContext));
-            msgContext.setRestThroughPOST(HTTPTransportUtils.isDoingRESTThoughPost(msgContext));
-            boolean isRest = msgContext.isDoingREST();
-
-            if (isRest) {
+            if (msgContext.isDoingREST()) {
                 dataOut = msgContext.getEnvelope().getBody().getFirstElement();
             } else {
                 dataOut = msgContext.getEnvelope();
@@ -241,9 +152,9 @@
                             (OutTransportInfo) msgContext.getProperty(
                                     Constants.OUT_TRANSPORT_INFO);
                     if (transportInfo != null) {
-                        format.setSOAP11(msgContext.isSOAP11());
-                        //this is the servlet2.3 way of setting encodings
-                        String contentType = findContentType(isRest, msgContext);
+                        boolean soap11 = msgContext.isSOAP11();
+                        format.setSOAP11(soap11);
+                        String contentType = format.getContentType();
                         String encoding = contentType + "; charset=" + format.getCharSetEncoding();
                         transportInfo.setContentType(encoding);
                     } else {
@@ -255,8 +166,7 @@
             }
             if (msgContext.getOperationContext() != null) {
                 msgContext.getOperationContext().setProperty(
-                        Constants.RESPONSE_WRITTEN,
-                        Constants.VALUE_TRUE);
+                        Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
             }
         } catch (XMLStreamException e) {
             throw new AxisFault(e);
@@ -267,27 +177,12 @@
         }
     }
 
-    private String findContentType(boolean isRest, MessageContext msgContext) {
-        if (isRest) {
-            if (msgContext.getProperty(HTTPConstants.HTTP_CONTENT_TYPE) != null) {
-                String contentType = (String) msgContext.getProperty(HTTPConstants.HTTP_CONTENT_TYPE);
-                //get the users setting from the axis2.xml parameters
-                //if present return that
-                //else return the default (application/xml)
-                return contentType;
-            } else {
-                return "application/xml";
-            }
-        } else {
-            return format.getContentType();
-        }
+    public void writeMessageWithToOutPutStream(MessageContext msgContext,
+                                               OutputStream out) {
     }
 
-    public void writeMessageWithCommons(
-            MessageContext msgContext,
-            EndpointReference toURL,
-            OMElement dataout)
-            throws AxisFault {
+    public void writeMessageWithCommons(MessageContext msgContext,
+                                        EndpointReference toURL, OMElement dataout) throws AxisFault {
         try {
             URL url = new URL(toURL.getAddress());
 
@@ -298,25 +193,19 @@
             if (soapActionString == null) {
                 soapActionString = "";
             }
-            //supporting RESTFacility..
 
+            //select the Message Sender depending on the REST status
+            AbstractSender sender = null;
             if (!msgContext.isDoingREST()) {
-                this.transportConfigurationPOST(
-                        msgContext,
-                        dataout,
-                        url,
-                        soapActionString);
-            }else {
-                if(msgContext.isRestThroughPOST()){
-                   this.transportConfigurationPOST(
-                            msgContext,
-                            dataout,
-                            url,
-                            soapActionString);
-                }else {
-                     this.transportConfigurationGET(msgContext, url);
-                }
+                sender = new SOAPSender();
+            } else {
+                sender = new RESTSender();
             }
+
+            sender.setFormat(this.format);
+            sender.transportConfiguration(msgContext, dataout, url,
+                    soapActionString);
+
         } catch (MalformedURLException e) {
             throw new AxisFault(e);
         } catch (HttpException e) {
@@ -324,224 +213,40 @@
         } catch (IOException e) {
             throw new AxisFault(e);
         }
-
-    }
-    // POST application/x-www-form-urlencoded
-
-    public class PostAxisRequestEntity implements RequestEntity {
-
-        private String charSetEnc;
-        private String postRequestBody;
-        private MessageContext msgCtxt;
-        private String contentType;
-
-        public PostAxisRequestEntity(String postRequestBody, String charSetEnc, MessageContext msgCtxt, String contentType) {
-            this.postRequestBody = postRequestBody;
-            this.charSetEnc = charSetEnc;
-            this.msgCtxt = msgCtxt;
-            this.contentType = contentType;
-        }
-
-        public boolean isRepeatable() {
-            return true;
-        }
-
-
-        public void writeRequest(OutputStream output) throws IOException {
-            output.write(postRequestBody.getBytes());
-        }
-
-        public long getContentLength() {
-            return this.postRequestBody.getBytes().length;
-        }
-
-
-        public String getContentType() {
-            return this.contentType;
-        }
-
-    }
-
-    //get the contentLength...
-    public class AxisRequestEntity implements RequestEntity {
-
-        private String charSetEnc;
-
-        private OMElement element;
-
-        private boolean chuncked;
-
-        private byte[] bytes;
-
-        private boolean doingMTOM = false;
-
-        private String soapActionString;
-
-        private MessageContext msgCtxt;
-
-        public AxisRequestEntity(
-                OMElement element,
-                boolean chuncked,
-                MessageContext msgCtxt,
-                String charSetEncoding,
-                String soapActionString) {
-            this.element = element;
-            this.chuncked = chuncked;
-            this.msgCtxt = msgCtxt;
-            this.doingMTOM = msgCtxt.isDoingMTOM();
-            this.charSetEnc = charSetEncoding;
-            this.soapActionString = soapActionString;
-        }
-
-        public boolean isRepeatable() {
-            return true;
-        }
-
-        public byte[] writeBytes() throws AxisFault {
-            try {
-                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
-
-                if (!doingMTOM) {
-                    OMOutputFormat format2 = new OMOutputFormat();
-                    format2.setCharSetEncoding(charSetEnc);
-                    element.serializeAndConsume(bytesOut, format2);
-                    return bytesOut.toByteArray();
-
-                } else {
-                    format.setCharSetEncoding(charSetEnc);
-                    format.setDoOptimize(true);
-                    element.serializeAndConsume(bytesOut, format);
-                    return bytesOut.toByteArray();
-                }
-            } catch (XMLStreamException e) {
-                throw new AxisFault(e);
-            } catch (FactoryConfigurationError e) {
-                throw new AxisFault(e);
-            }
-        }
-
-        private void handleOMOutput(OutputStream out, boolean doingMTOM)
-                throws XMLStreamException {
-            format.setDoOptimize(doingMTOM);
-            element.serializeAndConsume(out, format);
-        }
-
-        public void writeRequest(OutputStream out) throws IOException {
-            try {
-                if (doingMTOM) { 
-                    if (chuncked) {
-                        this.handleOMOutput(out, doingMTOM);
-                    } else {
-                        if (bytes == null) {
-                            bytes = writeBytes();
-                        }
-                        out.write(bytes);
-                    }
-
-                } else {
-                    if (chuncked) {
-                        this.handleOMOutput(out, doingMTOM);
-                    } else {
-                        if (bytes == null) {
-                            bytes = writeBytes();
-                        }
-                        out.write(bytes);
-                    }
-                }
-                out.flush();
-            } catch (XMLStreamException e) {
-                throw new AxisFault(e);
-            } catch (FactoryConfigurationError e) {
-                throw new AxisFault(e);
-            } catch (IOException e) {
-                throw new AxisFault(e);
-            }
-        }
-
-        public long getContentLength() {
-            try {
-                if (doingMTOM) {    //chagened
-                    if (chuncked) {
-                        return -1;
-                    } else {
-                        if (bytes == null) {
-                            bytes = writeBytes();
-                        }
-                        return bytes.length;
-                    }
-                } else {
-                    if (chuncked) {
-                        return -1;
-                    } else {
-                        if (bytes == null) {
-                            bytes = writeBytes();
-                        }
-                        return bytes.length;
-                    }
-                }
-            } catch (AxisFault e) {
-                return -1;
-            }
-        }
-
-        public String getContentType() {
-
-            String encoding = format.getCharSetEncoding();
-            String contentType = format.getContentType();
-            if (encoding != null) {
-                contentType += "; charset=" + encoding;
-            }
-
-            // action header is not mandated in SOAP 1.2. So putting it, if available
-            if (!msgCtxt.isSOAP11() && soapActionString != null && !"".equals(soapActionString.trim())) {
-                contentType = contentType + ";action=\"" + soapActionString + "\";";
-            }
-            return contentType;
-        }
     }
 
-    /*
-    * (non-Javadoc)
-    *
-    * @see org.apache.axis2.transport.TransportSender#cleanUp(org.apache.axis2.context.MessageContext)
-    */
     public void cleanUp(MessageContext msgContext) throws AxisFault {
-        HttpMethod httpMethod =
-                (HttpMethod) msgContext.getProperty(HTTP_METHOD);
+        HttpMethod httpMethod = (HttpMethod) msgContext
+                .getProperty(HTTP_METHOD);
         if (httpMethod != null) {
             httpMethod.releaseConnection();
         }
-
     }
 
-    public void init(
-            ConfigurationContext confContext,
-            TransportOutDescription transportOut)
-            throws AxisFault {
+    public void init(ConfigurationContext confContext,
+                     TransportOutDescription transportOut) throws AxisFault {
         //<parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter> or
         //<parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> is
         // checked
-        Parameter version =
-                transportOut.getParameter(HTTPConstants.PROTOCOL_VERSION);
+        Parameter version = transportOut
+                .getParameter(HTTPConstants.PROTOCOL_VERSION);
         if (version != null) {
             if (HTTPConstants.HEADER_PROTOCOL_11.equals(version.getValue())) {
-                this.httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
-                Parameter transferEncoding =
-                        transportOut.getParameter(
-                                HTTPConstants.HEADER_TRANSFER_ENCODING);
+                httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
+                Parameter transferEncoding = transportOut
+                        .getParameter(HTTPConstants.HEADER_TRANSFER_ENCODING);
                 if (transferEncoding != null
-                        && HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(
-                        transferEncoding.getValue())) {
+                        && HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED
+                        .equals(transferEncoding.getValue())) {
                     this.chuncked = true;
                 }
-            } else if (
-                    HTTPConstants.HEADER_PROTOCOL_10.equals(version.getValue())) {
-                this.httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
+            } else if (HTTPConstants.HEADER_PROTOCOL_10.equals(version
+                    .getValue())) {
+                httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
             } else {
-                throw new AxisFault(
-                        "Parameter "
-                                + HTTPConstants.PROTOCOL_VERSION
-                                + " Can have values only HTTP/1.0 or HTTP/1.1");
+                throw new AxisFault("Parameter "
+                        + HTTPConstants.PROTOCOL_VERSION
+                        + " Can have values only HTTP/1.0 or HTTP/1.1");
             }
         }
 
@@ -566,432 +271,6 @@
             //If there's a problem log it and use the default values
             log.error("Invalid timeout value format: not a number", nfe);
         }
-    }
 
-    private void transportConfigurationPOST(
-            MessageContext msgContext,
-            OMElement dataout,
-            URL url,
-            String soapActionString)
-            throws MalformedURLException, AxisFault, IOException {
-
-        //execuite the HtttpMethodBase - a connection manager can be given for handle multiple
-        httpClient = new HttpClient();
-        //hostConfig handles the socket functions..
-        //HostConfiguration hostConfig = getHostConfiguration(msgContext, url);
-
-        //Get the timeout values set in the runtime
-        getTimeoutValues(msgContext);
-
-        // SO_TIMEOUT -- timeout for blocking reads
-        httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
-        // timeout for initial connection
-        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
-
-        //todo giving proxy and NTLM support
-
-        PostMethod postMethod = new PostMethod(url.toString());
-        String contentType = findContentType(true, msgContext);
-
-        msgContext.setProperty(HTTP_METHOD, postMethod);
-        String charEncoding =
-                (String) msgContext.getProperty(
-                        MessageContext.CHARACTER_SET_ENCODING);
-        if (charEncoding == null) {
-            charEncoding = MessageContext.DEFAULT_CHAR_SET_ENCODING;
-        }
-
-        //if POST as application/x-www-form-urlencoded
-        RequestData reqData = null;
-        if (contentType.equalsIgnoreCase(HTTPConstants.MEDIA_TYPE_X_WWW_FORM)) {
-            reqData = createRequest(msgContext);
-            postMethod.setPath(url.getPath() + ((reqData.urlRequest) != null ? ("?" + reqData.urlRequest) : ""));
-            postMethod.setRequestEntity(new PostAxisRequestEntity(reqData.bodyRequest, charEncoding, msgContext, contentType));
-
-        } else {
-            postMethod.setPath(url.getPath());
-
-
-            postMethod.setRequestEntity(
-                    new AxisRequestEntity(
-                            dataout,
-                            chuncked,
-                            msgContext,
-                            charEncoding,
-                            soapActionString));
-        }
-
-        if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)
-                && chuncked) {
-            postMethod.setContentChunked(true);
-        }
-        postMethod.setRequestHeader(
-                HTTPConstants.HEADER_USER_AGENT,
-                "Axis/2.0");
-        if (msgContext.isSOAP11() && !msgContext.isDoingREST()) {
-            postMethod.setRequestHeader(
-                    HTTPConstants.HEADER_SOAP_ACTION,
-                    soapActionString);
-        }
-        postMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());
-        if (httpVersion != null) {
-            if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
-
-                httpClient.getParams().setVersion(HttpVersion.HTTP_1_0);
-                postMethod.setRequestHeader(
-                        HTTPConstants.HEADER_CONNECTION,
-                        HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
-            } else {
-                // allowing keep-alive for 1.1
-                postMethod.setRequestHeader(
-                        HTTPConstants.HEADER_CONNECTION,
-                        HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
-                postMethod.setRequestHeader(
-                        HTTPConstants.HEADER_EXPECT,
-                        HTTPConstants.HEADER_EXPECT_100_Continue);
-            }
-        }
-
-        /**
-         * main excecution takes place..
-         */
-
-        HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);
-
-        this.httpClient.executeMethod(config, postMethod);
-
-        if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
-            processResponse(postMethod, msgContext);
-            return;
-        } else if (postMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
-            return;
-        } else if (postMethod.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
-            Header contenttypeHheader = postMethod.getResponseHeader(
-                    HTTPConstants.HEADER_CONTENT_TYPE);
-
-            if (contenttypeHheader != null) {
-                String value = contenttypeHheader.getValue();
-                if (value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) >= 0 ||
-                        value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >= 0) {
-                    processResponse(postMethod, msgContext);
-                    return;
-                }
-            }
-        }
-        throw new AxisFault(
-                Messages.getMessage(
-                        "transportError",
-                        String.valueOf(postMethod.getStatusCode()),
-                        postMethod.getResponseBodyAsString()));
-    }
-
-    /**
-     * This is used to get the dynamically set time out values from the
-     * message context. If the values are not available or invalid then
-     * teh default values or the values set by teh configuration will be used
-     *
-     * @param msgContext
-     */
-    private void getTimeoutValues(MessageContext msgContext) {
-        try {
-            // If the SO_TIMEOUT of CONNECTION_TIMEOUT is set by dynamically the
-            // override the static config
-            Integer tempSoTimeoutProperty = (Integer) msgContext
-                    .getProperty(HTTPConstants.SO_TIMEOUT);
-            Integer tempConnTimeoutProperty = (Integer) msgContext
-                    .getProperty(HTTPConstants.CONNECTION_TIMEOUT);
-
-            if (tempSoTimeoutProperty != null) {
-                soTimeout = tempSoTimeoutProperty.intValue();
-            }
-
-            if (tempConnTimeoutProperty != null) {
-                connectionTimeout = tempConnTimeoutProperty.intValue();
-            }
-        } catch (NumberFormatException nfe) {
-            //If there's a problem log it and use the default values
-            log.error("Invalid timeout value format: not a number", nfe);
-        }
-    }
-
-    private void processResponse(HttpMethodBase httpMethod, MessageContext msgContext) throws IOException {
-        obatainHTTPHeaderInformation(httpMethod, msgContext);
-        InputStream in = httpMethod.getResponseBodyAsStream();
-        if (in == null) {
-            throw new AxisFault(
-                    Messages.getMessage("canNotBeNull", "InputStream"));
-        }
-        msgContext.getOperationContext().setProperty(
-                MessageContext.TRANSPORT_IN,
-                in);
-    }
-
-    //Method to return the parameter string to pass with the URL when using GET
-
-    public String getParam(MessageContext msgContext) {
-        OMElement dataOut;
-        dataOut = msgContext.getEnvelope().getBody().getFirstElement();
-        Iterator iter1 = dataOut.getChildElements();
-        ArrayList paraList = new ArrayList();
-
-        while (iter1.hasNext()) {
-            OMElement ele = (OMElement) iter1.next();
-            String parameter;
-            parameter = ele.getLocalName() + "=" + ele.getText();
-            paraList.add(parameter);
-        }
-
-        String paraString = "";
-        int count = paraList.size();
-        for (int i = 0; i < count; i++) {
-            String c = (String) paraList.get(i);
-            paraString = paraString + "&" + c;
-        }
-        return paraString;
-    }
-
-    private void transportConfigurationGET(MessageContext msgContext, URL url)
-            throws MalformedURLException, AxisFault, IOException {
-
-        String param = getParam(msgContext);
-        GetMethod getMethod = new GetMethod();
-        getMethod.setPath(url.getFile() + "?" + param);
-
-        //Serialization as "application/x-www-form-urlencoded"
-
-        String charEncoding =
-                (String) msgContext.getProperty(
-                        MessageContext.CHARACTER_SET_ENCODING);
-        if (charEncoding == null) //Default encoding scheme
-            getMethod.setRequestHeader(
-                    HTTPConstants.HEADER_CONTENT_TYPE,
-                    HTTPConstants.MEDIA_TYPE_X_WWW_FORM + "; charset="
-                            + MessageContext.DEFAULT_CHAR_SET_ENCODING);
-        else
-            getMethod.setRequestHeader(
-                    HTTPConstants.HEADER_CONTENT_TYPE,
-                    HTTPConstants.MEDIA_TYPE_X_WWW_FORM + "; charset=" + charEncoding);
-
-        this.httpClient = new HttpClient();
-
-
-        HostConfiguration hostConfig = this.getHostConfiguration(httpClient, msgContext, url);
-        //this.getHostConfiguration(msgContext, url);
-
-        //Get the timeout values set in the runtime
-        getTimeoutValues(msgContext);
-
-        // SO_TIMEOUT -- timeout for blocking reads
-        httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
-        // timeout for initial connection
-        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
-
-        /**
-         * with HostConfiguration
-         */
-        this.httpClient.executeMethod(hostConfig, getMethod, null);
-
-        if (getMethod.getStatusCode() == HttpStatus.SC_OK) {
-            processResponse(getMethod, msgContext);
-        } else if (getMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
-            return;
-        } else if (getMethod.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
-
-            Header contenttypeHheader = getMethod.getResponseHeader(
-                    HTTPConstants.HEADER_CONTENT_TYPE);
-
-            String value = contenttypeHheader.getValue();
-            if (value != null) {
-                if (value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) >= 0 ||
-                        value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >= 0) {
-                    processResponse(getMethod, msgContext);
-                }
-
-            }
-        } else {
-            throw new AxisFault(
-                    Messages.getMessage(
-                            "transportError",
-                            String.valueOf(getMethod.getStatusCode()),
-                            getMethod.getResponseBodyAsString()));
-        }
     }
-
-    /**
-     * Collect the HTTP header information and set them in the message context
-     *
-     * @param method
-     * @param msgContext
-     */
-    private void obatainHTTPHeaderInformation(HttpMethodBase method, MessageContext msgContext) {
-        Header header =
-                method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
-        if (header != null) {
-            HeaderElement[] headers = header.getElements();
-            for (int i = 0; i < headers.length; i++) {
-                NameValuePair charsetEnc = headers[i]
-                        .getParameterByName(HTTPConstants.CHAR_SET_ENCODING);
-                if (headers[i]
-                        .getName()
-                        .equalsIgnoreCase(
-                                HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)) {
-                    OperationContext opContext =
-                            msgContext.getOperationContext();
-                    if (opContext != null) {
-                        opContext.setProperty(
-                                HTTPConstants.MTOM_RECIVED_CONTENT_TYPE,
-                                header.getValue());
-                    }
-                } else if (charsetEnc != null) {
-
-                    msgContext
-                            .setProperty(
-                                    MessageContext.CHARACTER_SET_ENCODING,
-                                    charsetEnc.getValue());  //change to the value, which is text/xml or application/xml+soap
-                }
-            }
-        }
-
-    }
-
-    /**
-     * getting host configuration to support standard http/s, proxy and NTLM support
-     */
-    private HostConfiguration getHostConfiguration(HttpClient client, MessageContext msgCtx, URL targetURL) throws AxisFault {
-        boolean isHostProxy = isProxyListed(msgCtx); //list the proxy
-        int port = targetURL.getPort();
-        if (port == -1) port = 80;
-        // to see the host is a proxy and in the proxy list - available in axis2.xml
-        HostConfiguration config = new HostConfiguration();
-
-        if (!isHostProxy) {
-            config.setHost(targetURL.getHost(), port, targetURL.getProtocol());
-        } else {
-            //proxy and NTLM configuration
-            this.configProxyAuthentication(client, proxyOutSetting, config, msgCtx);
-        }
-
-        return config;
-    }
-
-    private boolean isProxyListed(MessageContext msgCtx) throws AxisFault {
-        boolean returnValue = false;
-        Parameter par = null;
-        proxyOutSetting = msgCtx.getConfigurationContext()
-                .getAxisConfiguration()
-                .getTransportOut(new QName(Constants.TRANSPORT_HTTP));
-        if (proxyOutSetting != null) {
-            par = proxyOutSetting.getParameter(HTTPConstants.PROXY);
-        }
-        OMElement hostElement = null;
-        if (par != null) {
-            hostElement =
-                    par.getParameterElement();
-        } else {
-            return returnValue;
-        }
-
-        if (hostElement != null) {
-            Iterator ite = hostElement.getAllAttributes();
-            while (ite.hasNext()) {
-                OMAttribute attribute = (OMAttribute) ite.next();
-                if (attribute.getLocalName().equalsIgnoreCase(PROXY_HOST_NAME)) {
-                    returnValue = true;
-                }
-            }
-        }
-        HttpTransportProperties.ProxyProperties proxyProperties = null;
-        if ((proxyProperties = (HttpTransportProperties.ProxyProperties) msgCtx
-                .getProperty(HTTPConstants.PROXY)) != null) {
-            if (proxyProperties.getProxyHostName() != null) {
-                returnValue = true;
-            }
-        }
-        return returnValue;
-    }
-
-    /**
-     * Helper method to Proxy and NTLM authentication
-     *
-     * @param client
-     * @param proxySetting
-     * @param config
-     */
-
-    private void configProxyAuthentication(HttpClient client,
-                                           TransportOutDescription proxySetting,
-                                           HostConfiguration config, MessageContext msgCtx) throws AxisFault {
-        Parameter proxyParam = proxySetting.getParameter(HTTPConstants.PROXY);
-        String value = (String) proxyParam.getValue();
-        String split[] = value.split(":");
-        //values being hard coded due best practise
-        String usrName = split[0];
-        String domain = split[1];
-        String passwd = split[2];
-        //
-        Credentials proxyCred = null;
-
-        String proxyHostName = null;
-        int proxyPort = -1;
-
-        if (proxyParam != null) {
-            OMElement proxyParamElement = proxyParam.getParameterElement();
-            Iterator ite = proxyParamElement.getAllAttributes();
-            while (ite.hasNext()) {
-                OMAttribute att = (OMAttribute) ite.next();
-                if (att.getLocalName().equalsIgnoreCase(PROXY_HOST_NAME)) {
-                    proxyHostName = att.getAttributeValue();
-                }
-                if (att.getLocalName().equalsIgnoreCase(PROXY_PORT)) {
-                    proxyPort = new Integer(att.getAttributeValue()).intValue();
-                }
-            }
-
-        }
-
-        if (domain.equals("") || domain == null || domain.equals(ANONYMOUS)) {
-            if (usrName.equals(ANONYMOUS) && passwd.equals(ANONYMOUS)) {
-                proxyCred = new UsernamePasswordCredentials("", "");
-            } else {
-                proxyCred = new UsernamePasswordCredentials(usrName,
-                        passwd); //proxy
-            }
-        } else {
-            proxyCred = new NTCredentials(usrName, passwd, proxyHostName,
-                    domain); //NTLM authentication with additionals prams
-        }
-
-
-        HttpTransportProperties.ProxyProperties proxyProperties = (HttpTransportProperties.ProxyProperties) msgCtx.getProperty(HTTPConstants.PROXY);
-        if (proxyProperties != null) {
-            if (proxyProperties.getProxyPort() != -1) {
-                proxyPort = proxyProperties.getProxyPort();
-            }
-            if (proxyProperties.getProxyHostName().equals("") || proxyProperties.getProxyHostName() != null) {
-                proxyHostName = proxyProperties.getProxyHostName();
-            } else {
-                throw new AxisFault("Proxy Name is not valied");
-            }
-            if (proxyProperties.getUserName().equals(ANONYMOUS) || proxyProperties.getPassWord().equals(ANONYMOUS)) {
-                proxyCred = new UsernamePasswordCredentials("", "");
-            } else {
-                usrName = proxyProperties.getUserName();
-                passwd = proxyProperties.getPassWord();
-                domain = proxyProperties.getPassWord();
-            }
-        }
-        client.getState().setProxyCredentials(AuthScope.ANY, proxyCred);
-        config.setProxy(proxyHostName, proxyPort);
-    }
-
-    //
-    private class RequestData {
-        String urlRequest;
-        String bodyRequest;
-    }
-
-    String urlRequest;
-    String bodyRequest;
 }
-
-

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java?rev=355804&r1=355803&r2=355804&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java Sat Dec 10 15:28:41 2005
@@ -32,6 +32,10 @@
     public static final String MEDIA_TYPE_TEXT_XML = "text/xml";
     public static final String MEDIA_TYPE_MULTIPART_RELATED = "multipart/related";
     public static final String MEDIA_TYPE_X_WWW_FORM = "application/x-www-form-urlencoded";
+    public static final String MEDIA_TYPE_APPLICATION_SOAP_XML = "application/soap+xml";
+
+    //public static final String HTTP_GET = "HTTP_GET";
+    //public static final String HTTP_POST = "HTTP_POST";
 
 
     /**

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=355804&r1=355803&r2=355804&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Sat Dec 10 15:28:41 2005
@@ -448,25 +448,25 @@
 
     }
 
-    public static boolean isDoingRESTThoughPost(MessageContext msgContext) {
-        boolean restThroughPost = true;
+    public static boolean isDoingHTTPPost(MessageContext msgContext) {
+        boolean httpPost = true;
 
-        if (msgContext.getParameter(Constants.Configuration.ENABLE_REST_THROUGH_GET)
+        if (msgContext.getParameter(Constants.Configuration.HTTP_METHOD_GET)
                 != null) {
-            restThroughPost =
+            httpPost =
                     Constants.VALUE_TRUE.equals(
                             msgContext.getParameter(
-                                    Constants.Configuration.ENABLE_REST_THROUGH_GET).getValue());
-            restThroughPost = false;
-        } else if (msgContext.getProperty(Constants.Configuration.ENABLE_REST_THROUGH_GET) != null) {
-            restThroughPost =
+                                    Constants.Configuration.HTTP_METHOD_GET).getValue());
+
+        } else if(msgContext.getProperty(Constants.Configuration.HTTP_METHOD_GET) != null) {
+            httpPost =
                     Constants.VALUE_TRUE.equals(
                             msgContext.getProperty(
-                                    Constants.Configuration.ENABLE_REST_THROUGH_GET));
-            restThroughPost = false;
+                                    Constants.Configuration.HTTP_METHOD_GET));
+           
         }
-        msgContext.setRestThroughPOST(!restThroughPost);
-        return restThroughPost;
+        msgContext.setDoingHttpPOST(!httpPost);
+        return httpPost;
 
     }
 }

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java?rev=355804&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java Sat Dec 10 15:28:41 2005
@@ -0,0 +1,375 @@
+/*
+ * Created on Nov 28, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis2.transport.http;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.MissingResourceException;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.soap.SOAP11Constants;
+import org.apache.axis2.soap.SOAP12Constants;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+
+
+public class RESTSender extends AbstractSender {
+
+	public void transportConfiguration(MessageContext msgContext,
+			OMElement dataout, URL url, String soapActionString) {
+		try {
+			msgContext.setDoingHttpPOST(HTTPTransportUtils
+					.isDoingHTTPPost(msgContext));
+
+			if (!msgContext.isDoingHttpPOST()) {
+				this.transportConfigurationGET(msgContext, url);
+			} else {
+				this.transportConfigurationPOST(msgContext, dataout, url,
+						soapActionString);
+			}
+		} catch (AxisFault e) {
+			e.printStackTrace();
+		} catch (MalformedURLException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	public void transportConfigurationPOST(MessageContext msgContext,
+			OMElement dataout, URL url, String soapActionString) {
+		//execuite the HtttpMethodBase - a connection manager can be given for
+		// handle multiple
+		httpClient = new HttpClient();
+		//hostConfig handles the socket functions..
+		//HostConfiguration hostConfig = getHostConfiguration(msgContext, url);
+
+		//Get the timeout values set in the runtime
+		getTimeoutValues(msgContext);
+
+		// SO_TIMEOUT -- timeout for blocking reads
+		httpClient.getHttpConnectionManager().getParams().setSoTimeout(
+				soTimeout);
+		// timeout for initial connection
+		httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(
+				connectionTimeout);
+
+		//todo giving proxy and NTLM support
+
+		PostMethod postMethod = new PostMethod(url.toString());
+		String httpContentType;
+		if (msgContext.getProperty(Constants.Configuration.CONTENT_TYPE)!=null){
+			httpContentType = (String)msgContext.getProperty(Constants.Configuration.CONTENT_TYPE);
+		}else{
+			httpContentType = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
+			}
+		
+
+		msgContext.setProperty(CommonsHTTPTransportSender.HTTP_METHOD,
+				postMethod);
+		String charEncoding = (String) msgContext
+				.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+		if (charEncoding == null) {
+			charEncoding = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+		}
+
+		//if POST as application/x-www-form-urlencoded
+		RequestData reqData = null;
+		
+		//System.out.print((String)msgContext.);
+			
+		if(httpContentType.equalsIgnoreCase(HTTPConstants.MEDIA_TYPE_X_WWW_FORM)){
+				reqData = createRequest(msgContext, dataout);
+				postMethod
+					.setPath(url.getPath()
+							+ ((reqData.urlRequest) != null ? ("?" + reqData.urlRequest)
+									: ""));
+				postMethod.setRequestEntity(new AxisRESTRequestEntity(
+                    reqData.bodyRequest, charEncoding, msgContext,
+                    httpContentType));
+
+		} else {
+			postMethod.setPath(url.getPath());
+
+			postMethod.setRequestEntity(new AxisRequestEntity(dataout,
+					chuncked, msgContext, charEncoding, soapActionString));
+		}
+
+		if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chuncked) {
+			postMethod.setContentChunked(true);
+		}
+		postMethod
+				.setRequestHeader(HTTPConstants.HEADER_USER_AGENT, "Axis/2.0");
+		if (msgContext.isSOAP11() && !msgContext.isDoingREST()) {
+			postMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION,
+					soapActionString);
+		}
+		postMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());
+		if (httpVersion != null) {
+			if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
+
+				httpClient.getParams().setVersion(HttpVersion.HTTP_1_0);
+				postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
+						HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
+			} else {
+				// allowing keep-alive for 1.1
+				postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
+						HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
+				postMethod.setRequestHeader(HTTPConstants.HEADER_EXPECT,
+						HTTPConstants.HEADER_EXPECT_100_Continue);
+			}
+		}
+
+		/**
+		 * main excecution takes place..
+		 */
+
+		try {
+			HostConfiguration config = this.getHostConfiguration(httpClient,
+					msgContext, url);
+
+			this.httpClient.executeMethod(config, postMethod);
+
+			if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
+				processResponse(postMethod, msgContext);
+				return;
+			} else if (postMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
+				return;
+			} else if (postMethod.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
+				Header contenttypeHheader = postMethod
+						.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
+
+				if (contenttypeHheader != null) {
+					String value = contenttypeHheader.getValue();
+					if (value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) >= 0
+							|| value
+									.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >= 0) {
+						processResponse(postMethod, msgContext);
+						return;
+					}
+				}
+			}
+			throw new AxisFault(Messages.getMessage("transportError", String
+					.valueOf(postMethod.getStatusCode()), postMethod
+					.getResponseBodyAsString()));
+		} catch (AxisFault e) {
+			e.printStackTrace();
+		} catch (HttpException e) {
+			e.printStackTrace();
+		} catch (MissingResourceException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	private void transportConfigurationGET(MessageContext msgContext, URL url)
+			throws MalformedURLException, AxisFault, IOException {
+
+		String param = getParam(msgContext);
+		GetMethod getMethod = new GetMethod();
+			getMethod.setPath(url.getFile() + "?" + param);
+			
+		//Serialization as "application/x-www-form-urlencoded"
+
+		String charEncoding = (String) msgContext
+				.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+		if (charEncoding == null) //Default encoding scheme
+			getMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
+					HTTPConstants.MEDIA_TYPE_X_WWW_FORM + "; charset="
+							+ MessageContext.DEFAULT_CHAR_SET_ENCODING);
+		else
+			getMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
+					HTTPConstants.MEDIA_TYPE_X_WWW_FORM + "; charset="
+							+ charEncoding);
+
+		this.httpClient = new HttpClient();
+
+		HostConfiguration hostConfig = this.getHostConfiguration(httpClient,
+				msgContext, url);
+		//this.getHostConfiguration(msgContext, url);
+
+		//Get the timeout values set in the runtime
+		getTimeoutValues(msgContext);
+
+		// SO_TIMEOUT -- timeout for blocking reads
+		httpClient.getHttpConnectionManager().getParams().setSoTimeout(
+				soTimeout);
+		// timeout for initial connection
+		httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(
+				connectionTimeout);
+
+		/**
+		 * with HostConfiguration
+		 */
+		this.httpClient.executeMethod(hostConfig, getMethod, null);
+
+		if (getMethod.getStatusCode() == HttpStatus.SC_OK) {
+			processResponse(getMethod, msgContext);
+		} else if (getMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
+			return;
+		} else if (getMethod.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
+
+			Header contenttypeHheader = getMethod
+					.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
+
+			String value = contenttypeHheader.getValue();
+			if (value != null) {
+				if (value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) >= 0
+						|| value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >= 0) {
+					processResponse(getMethod, msgContext);
+				}
+
+			}
+		} else {
+			throw new AxisFault(Messages.getMessage("transportError", String
+					.valueOf(getMethod.getStatusCode()), getMethod
+					.getResponseBodyAsString()));
+		}
+	}
+
+	public String getParam(MessageContext msgContext) {
+		OMElement dataOut;
+		dataOut = msgContext.getEnvelope().getBody().getFirstElement();
+		Iterator iter1 = dataOut.getChildElements();
+		ArrayList paraList = new ArrayList();
+
+		while (iter1.hasNext()) {
+			OMElement ele = (OMElement) iter1.next();
+			String parameter;
+			parameter = ele.getLocalName() + "=" + ele.getText();
+			paraList.add(parameter);
+		}
+
+		String paraString = "";
+		int count = paraList.size();
+		for (int i = 0; i < count; i++) {
+			String c = (String) paraList.get(i);
+			paraString = paraString + "&" + c;
+		}
+		
+		return paraString;
+	}
+
+	public RequestData createRequest(MessageContext msgContext,
+			OMElement dataout) {
+		//Obtain two strings;one to go in the url and rest to pass in the body
+		// when doing POST in application/x-www-form-urlencoded form.
+		RequestData data = new RequestData();
+		Iterator iter1 = dataout.getChildElements();
+		ArrayList paraList = new ArrayList();
+		ArrayList urlList = new ArrayList();
+
+		//TODO: s is ALWAYS EMPTY. so what gets added to urllist????
+		String[] s = new String[] {};
+		OMElement bodypara = OMAbstractFactory.getOMFactory().createOMElement(
+				"temp", null);
+
+		while (iter1.hasNext()) {
+			OMElement ele = (OMElement) iter1.next();
+			boolean has = false;
+
+			for (int i = 0; i < s.length; i++) {
+				if (s[i].equals(ele.getLocalName())) {
+					has = true;
+					break;
+				}
+			}
+			String parameter1;
+
+			if (has) {
+				parameter1 = ele.getLocalName() + "=" + ele.getText();
+				urlList.add(parameter1);
+
+			} else {
+				bodypara.addChild(ele);
+			}
+		}
+
+		String urlString = "";
+		for (int i = 0; i < urlList.size(); i++) {
+			String c = (String) urlList.get(i);
+			urlString = urlString + "&" + c;
+			data.urlRequest = urlString;
+		}
+
+		Iterator it = bodypara.getChildElements();
+		while (it.hasNext()) {
+			OMElement ele1 = (OMElement) it.next();
+			String parameter2;
+			parameter2 = ele1.getLocalName() + "=" + ele1.getText();
+			paraList.add(parameter2);
+		}
+
+		String paraString = "";
+		for (int j = 0; j < paraList.size(); j++) {
+			String b = (String) paraList.get(j);
+			paraString = paraString + "&" + b;
+			data.bodyRequest = paraString;
+		}
+		return data;
+	}
+
+	private class RequestData {
+		private String urlRequest;
+
+		private String bodyRequest;
+	}
+
+	public class AxisRESTRequestEntity implements RequestEntity {
+
+		private String charSetEnc;
+
+		private String postRequestBody;
+
+		private MessageContext msgCtxt;
+
+		private String contentType;
+
+		public AxisRESTRequestEntity(String postRequestBody, String charSetEnc,
+                                     MessageContext msgCtxt, String contentType) {
+			this.postRequestBody = postRequestBody;
+			this.charSetEnc = charSetEnc;
+			this.msgCtxt = msgCtxt;
+			this.contentType = contentType;
+		}
+
+		public boolean isRepeatable() {
+			return true;
+		}
+
+		public void writeRequest(OutputStream output) throws IOException {
+			output.write(postRequestBody.getBytes());
+		}
+
+		public long getContentLength() {
+			return this.postRequestBody.getBytes().length;
+		}
+
+		public String getContentType() {
+			return this.contentType;
+		}
+
+	}
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPSender.java?rev=355804&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPSender.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPSender.java Sat Dec 10 15:28:41 2005
@@ -0,0 +1,276 @@
+/*
+ * Created on Nov 28, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis2.transport.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMOutputFormat;
+import org.apache.axis2.soap.SOAP11Constants;
+import org.apache.axis2.soap.SOAP12Constants;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+
+
+public class SOAPSender extends AbstractSender {
+
+    public void transportConfiguration(MessageContext msgContext,
+                                       OMElement dataout, URL url, String soapActionString)
+            throws MalformedURLException, AxisFault, IOException {
+
+        // execute the HtttpMethodBase - a connection manager can be given for
+        // handle multiple
+        httpClient = new HttpClient();
+        //hostConfig handles the socket functions..
+        //HostConfiguration hostConfig = getHostConfiguration(msgContext, url);
+
+        //Get the timeout values set in the runtime
+        getTimeoutValues(msgContext);
+
+        // SO_TIMEOUT -- timeout for blocking reads
+        httpClient.getHttpConnectionManager().getParams().setSoTimeout(
+                soTimeout);
+        // timeout for initial connection
+        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(
+                connectionTimeout);
+
+        //todo giving proxy and NTLM support
+
+
+        PostMethod postMethod = new PostMethod(url.toString());
+
+        msgContext.setProperty(CommonsHTTPTransportSender.HTTP_METHOD,
+                postMethod);
+        String charEncoding =
+                (String) msgContext.getProperty(
+                        MessageContext.CHARACTER_SET_ENCODING);
+        if (charEncoding == null) {
+            charEncoding = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+        }
+
+        postMethod.setPath(url.getPath());
+
+        postMethod.setRequestEntity(new AxisSOAPRequestEntity(dataout, chuncked,
+                msgContext, charEncoding, soapActionString));
+
+        if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chuncked) {
+            postMethod.setContentChunked(true);
+        }
+        postMethod
+                .setRequestHeader(HTTPConstants.HEADER_USER_AGENT, "Axis/2.0");
+
+
+        if (msgContext.isSOAP11()) {
+            postMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION,
+                    soapActionString);
+        }else{
+
+        }
+        postMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());
+        if (httpVersion != null) {
+            if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
+
+                httpClient.getParams().setVersion(HttpVersion.HTTP_1_0);
+                postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
+                        HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
+            } else {
+                // allowing keep-alive for 1.1
+                postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
+                        HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
+                postMethod.setRequestHeader(HTTPConstants.HEADER_EXPECT,
+                        HTTPConstants.HEADER_EXPECT_100_Continue);
+            }
+        }
+
+        /*
+           * main excecution takes place..
+           */
+
+        HostConfiguration config = this.getHostConfiguration(httpClient,
+                msgContext, url);
+
+
+        this.httpClient.executeMethod(config, postMethod);
+        /*
+           * Execution is over
+           */
+        if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
+            processResponse(postMethod, msgContext);
+            return;
+        } else if (postMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
+            return;
+        } else if (postMethod.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
+            Header contentTypeHeader = postMethod
+                    .getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
+
+            if (contentTypeHeader != null) {
+                String value = contentTypeHeader.getValue();
+                if (value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) >= 0
+                        || value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >= 0) {
+                    processResponse(postMethod, msgContext);
+                    return;
+                }
+            }
+        }
+        throw new AxisFault(Messages.getMessage("transportError", String
+                .valueOf(postMethod.getStatusCode()), postMethod
+                .getResponseBodyAsString()));
+
+    }
+
+    public class AxisSOAPRequestEntity implements RequestEntity {
+
+        private String charSetEnc;
+
+        private OMElement element;
+
+        private boolean chuncked;
+
+        private byte[] bytes;
+
+        private boolean doingMTOM = false;
+
+        private String soapActionString;
+
+        private MessageContext msgCtxt;
+
+        public AxisSOAPRequestEntity(
+                OMElement element,
+                boolean chuncked,
+                MessageContext msgCtxt,
+                String charSetEncoding,
+                String soapActionString) {
+            this.element = element;
+            this.chuncked = chuncked;
+            this.msgCtxt = msgCtxt;
+            this.doingMTOM = msgCtxt.isDoingMTOM();
+            this.charSetEnc = charSetEncoding;
+            this.soapActionString = soapActionString;
+        }
+
+        public boolean isRepeatable() {
+            return true;
+        }
+
+        public byte[] writeBytes() throws AxisFault {
+            try {
+                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+
+                if (!doingMTOM) {
+                    OMOutputFormat format2 = new OMOutputFormat();
+                    format2.setCharSetEncoding(charSetEnc);
+                    element.serializeAndConsume(bytesOut, format2);
+                    return bytesOut.toByteArray();
+
+                } else {
+                    format.setCharSetEncoding(charSetEnc);
+                    format.setDoOptimize(true);
+                    element.serializeAndConsume(bytesOut, format);
+                    return bytesOut.toByteArray();
+                }
+            } catch (XMLStreamException e) {
+                throw new AxisFault(e);
+            } catch (FactoryConfigurationError e) {
+                throw new AxisFault(e);
+            }
+        }
+
+        private void handleOMOutput(OutputStream out, boolean doingMTOM)
+                throws XMLStreamException {
+            format.setDoOptimize(doingMTOM);
+            element.serializeAndConsume(out, format);
+        }
+
+        public void writeRequest(OutputStream out) throws IOException {
+            try {
+                if (doingMTOM) { //chagened ..
+                    if (chuncked) {
+                        this.handleOMOutput(out, doingMTOM);
+                    } else {
+                        if (bytes == null) {
+                            bytes = writeBytes();
+                        }
+                        out.write(bytes);
+                    }
+
+                } else {
+                    if (chuncked) {
+                        this.handleOMOutput(out, doingMTOM);
+                    } else {
+                        if (bytes == null) {
+                            bytes = writeBytes();
+                        }
+                        out.write(bytes);
+                    }
+                }
+                out.flush();
+            } catch (XMLStreamException e) {
+                throw new AxisFault(e);
+            } catch (FactoryConfigurationError e) {
+                throw new AxisFault(e);
+            } catch (IOException e) {
+                throw new AxisFault(e);
+            }
+        }
+
+        public long getContentLength() {
+            try {
+                if (doingMTOM) {    //chagened
+                    if (chuncked) {
+                        return -1;
+                    } else {
+                        if (bytes == null) {
+                            bytes = writeBytes();
+                        }
+                        return bytes.length;
+                    }
+                } else {
+                    if (chuncked) {
+                        return -1;
+                    } else {
+                        if (bytes == null) {
+                            bytes = writeBytes();
+                        }
+                        return bytes.length;
+                    }
+                }
+            } catch (AxisFault e) {
+                return -1;
+            }
+        }
+
+        public String getContentType() {
+
+            String encoding = format.getCharSetEncoding();
+            String contentType = format.getContentType();
+            if (encoding != null) {
+                contentType += "; charset=" + encoding;
+            }
+
+            // action header is not mandated in SOAP 1.2. So putting it, if available
+            if (!msgCtxt.isSOAP11() && soapActionString != null && !"".equals(soapActionString.trim())) {
+                contentType = contentType + ";action=\"" + soapActionString + "\";";
+            }
+            return contentType;
+        }
+    }
+}