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 sa...@apache.org on 2012/05/22 12:10:03 UTC
svn commit: r1341384 [1/2] - in /axis/axis2/java/core/trunk: ./
modules/parent/ modules/transport/http/
modules/transport/http/src/org/apache/axis2/transport/http/
modules/transport/http/src/org/apache/axis2/transport/http/impl/
modules/transport/http/...
Author: sagara
Date: Tue May 22 10:10:01 2012
New Revision: 1341384
URL: http://svn.apache.org/viewvc?rev=1341384&view=rev
Log:
Merged AXIS2-4318 changes to the trunk.
Added:
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPAuthenticator.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/HTTPAuthenticator.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportConstants.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportConstants.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportSender.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/HTTPTransportSender.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/
- copied from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/
- copied from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPClient3TransportSender.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPClient3TransportSender.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java
- copied, changed from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxyConfigurator.java
- copied unchanged from r1335355, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxyConfigurator.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
- copied, changed from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPTransportHeaders.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPTransportHeaders.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HttpTransportPropertiesImpl.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HttpTransportPropertiesImpl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/RESTRequestEntity2Impl.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/RESTRequestEntity2Impl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/RESTRequestEntityImpl.java
- copied unchanged from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/RESTRequestEntityImpl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/
- copied from r1327468, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java
- copied unchanged from r1327468, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPClient4TransportSender.java
- copied unchanged from r1329571, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPClient4TransportSender.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java
- copied, changed from r1332141, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPProxyConfigurator.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
- copied, changed from r1332141, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java
- copied unchanged from r1327468, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java
- copied, changed from r1327468, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java
- copied unchanged from r1327468, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java
- copied unchanged from r1327468, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
- copied unchanged from r1295542, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3SenderTest.java
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
- copied unchanged from r1295542, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient3TransportSenderTest.java
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4SenderTest.java
- copied unchanged from r1332141, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4SenderTest.java
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4TransportSenderTest.java
- copied unchanged from r1329571, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4TransportSenderTest.java
Modified:
axis/axis2/java/core/trunk/ (props changed)
axis/axis2/java/core/trunk/modules/parent/pom.xml
axis/axis2/java/core/trunk/modules/transport/http/pom.xml
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.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/HTTPWorker.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HttpTransportProperties.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/HTTPProxyConfigurationUtil.java
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderClientSideTest.java
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/CommonsHTTPTransportSenderTest.java
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java
Propchange: axis/axis2/java/core/trunk/
------------------------------------------------------------------------------
Merged /axis/axis2/java/core/branches/AXIS2-4318:r1230452,1295542,1324772,1327468,1329571,1332141,1335355,1335357,1340985
Modified: axis/axis2/java/core/trunk/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/parent/pom.xml?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/parent/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/parent/pom.xml Tue May 22 10:10:01 2012
@@ -90,6 +90,7 @@
<geronimo.spec.saaj.version>1.0.1</geronimo.spec.saaj.version>
<geronimo.spec.jaxws.version>1.0</geronimo.spec.jaxws.version>
<httpcore.version>4.0</httpcore.version>
+ <httpclient.version>4.0</httpclient.version>
<intellij.version>5.0</intellij.version>
<jalopy.version>1.5rc3</jalopy.version>
<jaxb.api.version>2.2.4</jaxb.api.version>
@@ -725,6 +726,11 @@
<version>${httpcore.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${httpclient.version}</version>
+ </dependency>
+ <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons.fileupload.version}</version>
Modified: axis/axis2/java/core/trunk/modules/transport/http/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/pom.xml?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/pom.xml Tue May 22 10:10:01 2012
@@ -106,8 +106,16 @@
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
</dependencies>
</project>
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Tue May 22 10:10:01 2012
@@ -19,65 +19,24 @@
package org.apache.axis2.transport.http;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
+
+import java.io.IOException;
+import java.net.URL;
+
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.NamedValue;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.transport.http.util.HTTPProxyConfigurationUtil;
-import org.apache.axis2.wsdl.WSDLConstants;
-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.HttpConnectionManager;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthPolicy;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.apache.commons.httpclient.protocol.Protocol;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.protocol.HTTP;
-import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.zip.GZIPInputStream;
public abstract class AbstractHTTPSender {
- protected static final String ANONYMOUS = "anonymous";
- protected static final String PROXY_HOST_NAME = "proxy_host";
- protected static final String PROXY_PORT = "proxy_port";
protected boolean chunked = false;
protected String httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
- private static final Log log = LogFactory.getLog(AbstractHTTPSender.class);
- protected static final String PROTOCOL_HTTP = "http";
- protected static final String PROTOCOL_HTTPS = "https";
+ private static final Log log = LogFactory.getLog(AbstractHTTPSender.class);
/**
* proxydiscription
@@ -109,638 +68,13 @@ public abstract class AbstractHTTPSender
+ " Can have values only HTTP/1.0 or HTTP/1.1");
}
}
- }
-
- /**
- * Collect the HTTP header information and set them in the message context
- *
- * @param method HttpMethodBase from which to get information
- * @param msgContext the MessageContext in which to place the information... OR NOT!
- * @throws AxisFault if problems occur
- */
- protected void obtainHTTPHeaderInformation(HttpMethodBase method,
- MessageContext msgContext) throws AxisFault {
- // Set RESPONSE properties onto the REQUEST message context. They will need to be copied off the request context onto
- // the response context elsewhere, for example in the OutInOperationClient.
- Map transportHeaders = new CommonsTransportHeaders(method.getResponseHeaders());
- msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, transportHeaders);
- msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, new Integer(method.getStatusCode()));
- Header header = method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
-
- if (header != null) {
- HeaderElement[] headers = header.getElements();
- MessageContext inMessageContext = msgContext.getOperationContext().getMessageContext(
- WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-
- Object contentType = header.getValue();
- Object charSetEnc = null;
-
- for (int i = 0; i < headers.length; i++) {
- NameValuePair charsetEnc = headers[i].getParameterByName(
- HTTPConstants.CHAR_SET_ENCODING);
- if (charsetEnc != null) {
- charSetEnc = charsetEnc.getValue();
- }
- }
-
- if (inMessageContext != null) {
- inMessageContext
- .setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
- inMessageContext
- .setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
- } else {
-
- // Transport details will be stored in a HashMap so that anybody interested can
- // retrieve them
- HashMap transportInfoMap = new HashMap();
- transportInfoMap.put(Constants.Configuration.CONTENT_TYPE, contentType);
- transportInfoMap.put(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
-
- //the HashMap is stored in the outgoing message.
- msgContext.setProperty(Constants.Configuration.TRANSPORT_INFO_MAP,
- transportInfoMap);
- }
- }
-
- String sessionCookie = null;
- // Process old style headers first
- Header[] cookieHeaders = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE);
- String customCoookiId = (String) msgContext.getProperty(Constants.CUSTOM_COOKIE_ID);
- for (int i = 0; i < cookieHeaders.length; i++) {
- HeaderElement[] elements = cookieHeaders[i].getElements();
- for (int e = 0; e < elements.length; e++) {
- HeaderElement element = elements[e];
- if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
- Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName())) {
- sessionCookie = processCookieHeader(element);
- }
- if (customCoookiId != null && customCoookiId.equalsIgnoreCase(element.getName())) {
- sessionCookie = processCookieHeader(element);
- }
- }
- }
- // Overwrite old style cookies with new style ones if present
- cookieHeaders = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE2);
- for (int i = 0; i < cookieHeaders.length; i++) {
- HeaderElement[] elements = cookieHeaders[i].getElements();
- for (int e = 0; e < elements.length; e++) {
- HeaderElement element = elements[e];
- if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
- Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName())) {
- sessionCookie = processCookieHeader(element);
- }
- if(customCoookiId!=null&&customCoookiId.equalsIgnoreCase(element.getName())){
- sessionCookie = processCookieHeader(element);
- }
- }
- }
-
- if (sessionCookie != null) {
- msgContext.getServiceContext().setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
- }
- }
-
- private String processCookieHeader(HeaderElement element) {
- String cookie = element.getName() + "=" + element.getValue();
- NameValuePair[] parameters = element.getParameters();
- for (int j = 0; parameters != null && j < parameters.length; j++) {
- NameValuePair parameter = parameters[j];
- cookie = cookie + "; " + parameter.getName() + "=" + parameter.getValue();
- }
- return cookie;
- }
-
- protected void processResponse(HttpMethodBase httpMethod,
- MessageContext msgContext)
- throws IOException {
- obtainHTTPHeaderInformation(httpMethod, msgContext);
-
- InputStream in = httpMethod.getResponseBodyAsStream();
- if (in == null) {
- throw new AxisFault(Messages.getMessage("canNotBeNull", "InputStream"));
- }
- Header contentEncoding =
- httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_ENCODING);
- if (contentEncoding != null) {
- if (contentEncoding.getValue().
- equalsIgnoreCase(HTTPConstants.COMPRESSION_GZIP)) {
- in = new GZIPInputStream(in);
- // If the content-encoding is identity we can basically ignore it.
- } else if (!"identity".equalsIgnoreCase(contentEncoding.getValue())) {
- throw new AxisFault("HTTP :" + "unsupported content-encoding of '"
- + contentEncoding.getValue() + "' found");
- }
- }
-
- OperationContext opContext = msgContext.getOperationContext();
- if (opContext != null) {
- opContext.setProperty(MessageContext.TRANSPORT_IN, in);
- }
- }
+ }
public abstract void send(MessageContext msgContext, URL url, String soapActionString)
- throws IOException;
-
- /**
- * getting host configuration to support standard http/s, proxy and NTLM support
- *
- * @param client active HttpClient
- * @param msgCtx active MessageContext
- * @param targetURL the target URL
- * @return a HostConfiguration set up with proxy information
- * @throws AxisFault if problems occur
- */
- protected HostConfiguration getHostConfiguration(HttpClient client,
- MessageContext msgCtx,
- URL targetURL)throws AxisFault {
-
- boolean isAuthenticationEnabled = isAuthenticationEnabled(msgCtx);
- int port = targetURL.getPort();
-
- String protocol = targetURL.getProtocol();
- if (port == -1) {
- if (PROTOCOL_HTTP.equals(protocol)) {
- port = 80;
- } else if (PROTOCOL_HTTPS.equals(protocol)) {
- port = 443;
- }
-
- }
-
- // to see the host is a proxy and in the proxy list - available in axis2.xml
- HostConfiguration config = new HostConfiguration();
-
- // one might need to set his own socket factory. Let's allow that case as well.
- Protocol protocolHandler =
- (Protocol)msgCtx.getOptions().getProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER);
-
- // setting the real host configuration
- // I assume the 90% case, or even 99% case will be no protocol handler case.
- if (protocolHandler == null) {
- config.setHost(targetURL.getHost(), port, targetURL.getProtocol());
- } else {
- config.setHost(targetURL.getHost(), port, protocolHandler);
- }
-
- if (isAuthenticationEnabled) {
- // Basic, Digest, NTLM and custom authentications.
- this.setAuthenticationInfo(client, msgCtx, config);
- }
- // proxy configuration
-
- if (HTTPProxyConfigurationUtil.isProxyEnabled(msgCtx, targetURL)) {
- if(log.isDebugEnabled()){
- log.debug("Configuring HTTP proxy.");
- }
- HTTPProxyConfigurationUtil.configure(msgCtx, client, config);
- }
-
- return config;
- }
-
- protected boolean isAuthenticationEnabled(MessageContext msgCtx) {
- return (msgCtx.getProperty(HTTPConstants.AUTHENTICATE) != null);
- }
-
- /*
- This will handle server Authentication, It could be either NTLM, Digest or Basic Authentication.
- Apart from that user can change the priory or add a custom authentication scheme.
- */
- protected void setAuthenticationInfo(HttpClient agent,
- MessageContext msgCtx,
- HostConfiguration config) throws AxisFault {
- HttpTransportProperties.Authenticator authenticator;
- Object obj = msgCtx.getProperty(HTTPConstants.AUTHENTICATE);
- if (obj != null) {
- if (obj instanceof HttpTransportProperties.Authenticator) {
- authenticator = (HttpTransportProperties.Authenticator) obj;
-
- String username = authenticator.getUsername();
- String password = authenticator.getPassword();
- String host = authenticator.getHost();
- String domain = authenticator.getDomain();
-
- int port = authenticator.getPort();
- String realm = authenticator.getRealm();
-
- /* If retrying is available set it first */
- isAllowedRetry = authenticator.isAllowedRetry();
-
- Credentials creds;
-
- HttpState tmpHttpState = null;
- HttpState httpState = (HttpState)msgCtx.getProperty(HTTPConstants.CACHED_HTTP_STATE);
- if (httpState != null) {
- tmpHttpState = httpState;
- } else {
- tmpHttpState = agent.getState();
- }
-
- agent.getParams()
- .setAuthenticationPreemptive(authenticator.getPreemptiveAuthentication());
-
- if (host != null) {
- if (domain != null) {
- /*Credentials for NTLM Authentication*/
- creds = new NTCredentials(username, password, host, domain);
- } else {
- /*Credentials for Digest and Basic Authentication*/
- creds = new UsernamePasswordCredentials(username, password);
- }
- tmpHttpState.setCredentials(new AuthScope(host, port, realm), creds);
- } else {
- if (domain != null) {
- /*Credentials for NTLM Authentication when host is ANY_HOST*/
- creds = new NTCredentials(username, password, AuthScope.ANY_HOST, domain);
- tmpHttpState.setCredentials(
- new AuthScope(AuthScope.ANY_HOST, port, realm), creds);
- } else {
- /*Credentials only for Digest and Basic Authentication*/
- creds = new UsernamePasswordCredentials(username, password);
- tmpHttpState.setCredentials(new AuthScope(AuthScope.ANY), creds);
- }
- }
- /* Customizing the priority Order */
- List schemes = authenticator.getAuthSchemes();
- if (schemes != null && schemes.size() > 0) {
- List authPrefs = new ArrayList(3);
- for (int i = 0; i < schemes.size(); i++) {
- if (schemes.get(i) instanceof AuthPolicy) {
- authPrefs.add(schemes.get(i));
- continue;
- }
- String scheme = (String) schemes.get(i);
- if (HttpTransportProperties.Authenticator.BASIC.equals(scheme)) {
- authPrefs.add(AuthPolicy.BASIC);
- } else if (HttpTransportProperties.Authenticator.NTLM.equals(scheme)) {
- authPrefs.add(AuthPolicy.NTLM);
- } else if (HttpTransportProperties.Authenticator.DIGEST.equals(scheme)) {
- authPrefs.add(AuthPolicy.DIGEST);
- }
- }
- agent.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
- authPrefs);
- }
-
- } else {
- throw new AxisFault("HttpTransportProperties.Authenticator class cast exception");
- }
- }
-
- }
-
- /**
- * Method used to copy all the common properties
- *
- * @param msgContext - The messageContext of the request message
- * @param url - The target URL
- * @param httpMethod - The http method used to send the request
- * @param httpClient - The httpclient used to send the request
- * @param soapActionString - The soap action atring of the request message
- * @return MessageFormatter - The messageFormatter for the relavent request message
- * @throws AxisFault - Thrown in case an exception occurs
- */
- protected MessageFormatter populateCommonProperties(MessageContext msgContext, URL url,
- HttpMethodBase httpMethod,
- HttpClient httpClient,
- String soapActionString)
- throws AxisFault {
-
- if (isAuthenticationEnabled(msgContext)) {
- httpMethod.setDoAuthentication(true);
- }
-
- MessageFormatter messageFormatter = TransportUtils.getMessageFormatter(
- msgContext);
-
- url = messageFormatter.getTargetAddress(msgContext, format, url);
-
- httpMethod.setPath(url.getPath());
-
- httpMethod.setQueryString(url.getQuery());
-
- httpMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
- messageFormatter.getContentType(msgContext, format,
- soapActionString));
-
- httpMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());
-
- if (msgContext.getOptions() != null && msgContext.getOptions().isManageSession()) {
- // setting the cookie in the out path
- Object cookieString = msgContext.getProperty(HTTPConstants.COOKIE_STRING);
-
- if (cookieString != null) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(cookieString);
- httpMethod.setRequestHeader(HTTPConstants.HEADER_COOKIE, buffer.toString());
- }
- }
-
- if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
- httpClient.getParams().setVersion(HttpVersion.HTTP_1_0);
- }
- return messageFormatter;
- }
-
- /**
- * This is used to get the dynamically set time out values from the
- * message context. If the values are not available or invalid then
- * the default values or the values set by the configuration will be used
- *
- * @param msgContext the active MessageContext
- * @param httpClient
- */
- protected void initializeTimeouts(MessageContext msgContext, HttpClient httpClient) {
- // 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);
- long timeout = msgContext.getOptions().getTimeOutInMilliSeconds();
-
- if (tempConnTimeoutProperty != null) {
- int connectionTimeout = tempConnTimeoutProperty.intValue();
- // timeout for initial connection
- httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
- } else {
- // set timeout in client
- if (timeout > 0) {
- httpClient.getHttpConnectionManager().getParams().setConnectionTimeout((int) timeout);
- }
- }
-
- if (tempSoTimeoutProperty != null) {
- int soTimeout = tempSoTimeoutProperty.intValue();
- // SO_TIMEOUT -- timeout for blocking reads
- httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
- httpClient.getParams().setSoTimeout(soTimeout);
- } else {
- // set timeout in client
- if (timeout > 0) {
- httpClient.getHttpConnectionManager().getParams().setSoTimeout((int) timeout);
- httpClient.getParams().setSoTimeout((int) timeout);
- }
- }
- }
-
- /**
- * This is used to get the dynamically set time out values from the
- * message context. If the values are not available or invalid then
- * the default values or the values set by the configuration will be used
- *
- * @param msgContext the active MessageContext
- * @param httpMethod method
- */
- protected void setTimeouts(MessageContext msgContext, HttpMethod httpMethod) {
- // 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);
- long timeout = msgContext.getOptions().getTimeOutInMilliSeconds();
-
- if (tempConnTimeoutProperty != null) {
- // timeout for initial connection
- httpMethod.getParams().setParameter("http.connection.timeout",
- tempConnTimeoutProperty);
- }
-
- if (tempSoTimeoutProperty != null) {
- // SO_TIMEOUT -- timeout for blocking reads
- httpMethod.getParams().setSoTimeout(tempSoTimeoutProperty);
- } else {
- // set timeout in client
- if (timeout > 0) {
- httpMethod.getParams().setSoTimeout((int) timeout);
- }
- }
- }
+ throws IOException;
public void setFormat(OMOutputFormat format) {
this.format = format;
- }
-
- protected HttpClient getHttpClient(MessageContext msgContext) {
- ConfigurationContext configContext = msgContext.getConfigurationContext();
-
- HttpClient httpClient = (HttpClient) msgContext.getProperty(
- HTTPConstants.CACHED_HTTP_CLIENT);
-
- if (httpClient == null) {
- httpClient = (HttpClient) configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
- }
-
- if (httpClient != null) {
- return httpClient;
- }
-
- synchronized (this) {
- httpClient = (HttpClient) msgContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
-
- if (httpClient == null) {
- httpClient = (HttpClient) configContext.getProperty(
- HTTPConstants.CACHED_HTTP_CLIENT);
- }
-
- if (httpClient != null) {
- return httpClient;
- }
-
- HttpConnectionManager connManager =
- (HttpConnectionManager) msgContext.getProperty(
- HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER);
- if (connManager == null) {
- connManager =
- (HttpConnectionManager) msgContext.getProperty(
- HTTPConstants.MUTTITHREAD_HTTP_CONNECTION_MANAGER);
- }
- if (connManager == null) {
- // reuse HttpConnectionManager
- synchronized (configContext) {
- connManager = (HttpConnectionManager) configContext.getProperty(
- HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER);
- if (connManager == null) {
- log.trace("Making new ConnectionManager");
- connManager = new MultiThreadedHttpConnectionManager();
- configContext.setProperty(
- HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, connManager);
- }
- }
- }
- /*
- * Create a new instance of HttpClient since the way
- * it is used here it's not fully thread-safe.
- */
- httpClient = new HttpClient(connManager);
-
- // Set the default timeout in case we have a connection pool starvation to 30sec
- httpClient.getParams().setConnectionManagerTimeout(30000);
-
- // Get the timeout values set in the runtime
- initializeTimeouts(msgContext, httpClient);
-
- return httpClient;
- }
- }
-
- protected void executeMethod(HttpClient httpClient, MessageContext msgContext, URL url,
- HttpMethod method) throws IOException {
- HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);
-
- // set the custom headers, if available
- addCustomHeaders(method, msgContext);
-
- // add compression headers if needed
- if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
- method.addRequestHeader(HTTPConstants.HEADER_ACCEPT_ENCODING,
- HTTPConstants.COMPRESSION_GZIP);
- }
-
- if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
- method.addRequestHeader(HTTPConstants.HEADER_CONTENT_ENCODING,
- HTTPConstants.COMPRESSION_GZIP);
- }
-
- if (msgContext.getProperty(HTTPConstants.HTTP_METHOD_PARAMS) != null) {
- HttpMethodParams params = (HttpMethodParams)msgContext
- .getProperty(HTTPConstants.HTTP_METHOD_PARAMS);
- method.setParams(params);
- }
-
- String cookiePolicy = (String) msgContext.getProperty(HTTPConstants.COOKIE_POLICY);
- if (cookiePolicy != null) {
- method.getParams().setCookiePolicy(cookiePolicy);
- }
- HttpState httpState = (HttpState)msgContext.getProperty(HTTPConstants.CACHED_HTTP_STATE);
-
- setTimeouts(msgContext, method);
-
- httpClient.executeMethod(config, method, httpState);
- }
-
- public void addCustomHeaders(HttpMethod method, MessageContext msgContext) {
-
- boolean isCustomUserAgentSet = false;
- // set the custom headers, if available
- Object httpHeadersObj = msgContext.getProperty(HTTPConstants.HTTP_HEADERS);
- if (httpHeadersObj != null) {
- if (httpHeadersObj instanceof List) {
- List httpHeaders = (List) httpHeadersObj;
- for (int i = 0; i < httpHeaders.size(); i++) {
- NamedValue nv = (NamedValue) httpHeaders.get(i);
- if (nv != null) {
- Header header = new Header(nv.getName(), nv.getValue());
- if (HTTPConstants.HEADER_USER_AGENT.equals(header.getName())) {
- isCustomUserAgentSet = true;
- }
- method.addRequestHeader(header);
- }
- }
-
- }
- if (httpHeadersObj instanceof Map) {
- Map httpHeaders = (Map) httpHeadersObj;
- for (Iterator iterator = httpHeaders.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry entry = (Map.Entry) iterator.next();
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
- if (HTTPConstants.HEADER_USER_AGENT.equals(key)) {
- isCustomUserAgentSet = true;
- }
- method.addRequestHeader(key, value);
- }
- }
- }
-
- // we have to consider the TRANSPORT_HEADERS map as well
- Map transportHeaders = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
- if (transportHeaders != null) {
- removeUnwantedHeaders(msgContext);
-
- Set headerEntries = transportHeaders.entrySet();
-
- for (Object headerEntry : headerEntries) {
- if (headerEntry instanceof Map.Entry) {
- Header[] headers = method.getRequestHeaders();
-
- boolean headerAdded = false;
- for (Header header : headers) {
- if (header.getName() != null &&
- header.getName().equals(((Map.Entry) headerEntry).getKey())) {
- headerAdded = true;
- break;
- }
- }
-
- if (!headerAdded) {
- method.addRequestHeader(((Map.Entry) headerEntry).getKey().toString(),
- ((Map.Entry) headerEntry).getValue().toString());
- }
- }
- }
- }
-
- if (!isCustomUserAgentSet) {
- String userAgentString = getUserAgent(msgContext);
- method.setRequestHeader(HTTPConstants.HEADER_USER_AGENT, userAgentString);
- }
-
- }
-
-
- /**
- * Remove unwanted headers from the transport headers map of outgoing request. These are headers which
- * should be dictated by the transport and not the user. We remove these as these may get
- * copied from the request messages
- *
- * @param msgContext the Axis2 Message context from which these headers should be removed
- */
- private void removeUnwantedHeaders(MessageContext msgContext) {
- Map headers = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
-
- if (headers == null || headers.isEmpty()) {
- return;
- }
-
- Iterator iter = headers.keySet().iterator();
- while (iter.hasNext()) {
- String headerName = (String) iter.next();
- if (HTTP.CONN_DIRECTIVE.equalsIgnoreCase(headerName) ||
- HTTP.TRANSFER_ENCODING.equalsIgnoreCase(headerName) ||
- HTTP.DATE_HEADER.equalsIgnoreCase(headerName) ||
- HTTP.CONTENT_TYPE.equalsIgnoreCase(headerName) ||
- HTTP.CONTENT_LEN.equalsIgnoreCase(headerName)) {
- iter.remove();
- }
- }
- }
-
- private String getUserAgent(MessageContext messageContext) {
- String userAgentString = "Axis2";
- boolean locked = false;
- if (messageContext.getParameter(HTTPConstants.USER_AGENT) != null) {
- OMElement userAgentElement =
- messageContext.getParameter(HTTPConstants.USER_AGENT).getParameterElement();
- userAgentString = userAgentElement.getText().trim();
- OMAttribute lockedAttribute = userAgentElement.getAttribute(new QName("locked"));
- if (lockedAttribute != null) {
- if (lockedAttribute.getAttributeValue().equalsIgnoreCase("true")) {
- locked = true;
- }
- }
- }
- // Runtime overing part
- if (!locked) {
- if (messageContext.getProperty(HTTPConstants.USER_AGENT) != null) {
- userAgentString = (String) messageContext.getProperty(HTTPConstants.USER_AGENT);
- }
- }
-
- return userAgentString;
- }
+ }
}
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java Tue May 22 10:10:01 2012
@@ -24,10 +24,11 @@ import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.MessageFormatter;
import org.apache.axis2.util.JavaUtils;
-import org.apache.commons.httpclient.methods.RequestEntity;
import javax.xml.stream.FactoryConfigurationError;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;
@@ -35,7 +36,7 @@ import java.util.zip.GZIPOutputStream;
* This Request Entity is used by the HTTPCommonsTransportSender. This wraps the
* Axis2 message formatter object.
*/
-public class AxisRequestEntity implements RequestEntity {
+public abstract class AxisRequestEntity {
private MessageFormatter messageFormatter;
@@ -114,7 +115,21 @@ public class AxisRequestEntity implement
return bytes.length;
}
- public String getContentType() {
+ public String getContentTypeAsString() {
return messageFormatter.getContentType(messageContext, format, soapAction);
}
+
+ public boolean isChunked() {
+ return chunked;
+ }
+
+ public void setChunked(boolean chunked) {
+ this.chunked = chunked;
+ }
+
+ public InputStream getRequestEntityContent() throws IOException {
+ return new ByteArrayInputStream(messageFormatter.getBytes(messageContext, format));
+ }
+
+
}
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java Tue May 22 10:10:01 2012
@@ -555,7 +555,23 @@ public class AxisServlet extends HttpSer
// AXIS2-4898: MultiThreadedHttpConnectionManager starts a thread that is not stopped by the
// shutdown of the connection manager. If we want to avoid a resource leak, we need to call
// shutdownAll here.
- MultiThreadedHttpConnectionManager.shutdownAll();
+ // TODO - This action need be changed according to current HTTPClient.
+ String clientVersion = getHTTPClientVersion();
+ if (clientVersion != null
+ && HTTPTransportConstants.HTTP_CLIENT_4_X_VERSION.equals(clientVersion)) {
+ // TODO - Handle for HTTPClient 4
+ } else {
+ MultiThreadedHttpConnectionManager.shutdownAll();
+ }
+
+ }
+
+ private String getHTTPClientVersion() {
+ Object version = configContext.getProperty(HTTPTransportConstants.HTTP_CLIENT_VERSION);
+ if (version != null) {
+ return String.valueOf(version);
+ }
+ return null;
}
/**
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Tue May 22 10:10:01 2012
@@ -31,11 +31,10 @@ import org.apache.axis2.description.Tran
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.transport.MessageFormatter;
import org.apache.axis2.transport.OutTransportInfo;
-import org.apache.axis2.transport.TransportSender;
import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl;
import org.apache.axis2.transport.http.server.AxisHttpResponse;
import org.apache.axis2.util.JavaUtils;
-import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -51,8 +50,7 @@ import java.util.List;
import java.util.Map;
import java.util.zip.GZIPOutputStream;
-public class CommonsHTTPTransportSender extends AbstractHandler implements
- TransportSender {
+public class CommonsHTTPTransportSender extends AbstractHandler implements HTTPTransportSender {
/**
* The {@link TransportOutDescription} object received by the call to
* {@link #init(ConfigurationContext, TransportOutDescription)}.
@@ -78,22 +76,29 @@ public class CommonsHTTPTransportSender
private int soTimeout = HTTPConstants.DEFAULT_SO_TIMEOUT;
private int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
-
+
+ /*
+ * It's Required to keep this method to keep backward compatibility because
+ * still it's possible to register CommonsHTTPTransportSender in the
+ * axis2.xml.
+ */
public void cleanup(MessageContext msgContext) throws AxisFault {
- HttpMethod httpMethod = (HttpMethod) msgContext.getProperty(HTTPConstants.HTTP_METHOD);
-
- if (httpMethod != null) {
- // TODO : Don't do this if we're not on the right thread! Can we confirm?
- log.trace("cleanup() releasing connection for " + httpMethod);
-
- httpMethod.releaseConnection();
- msgContext.removeProperty(HTTPConstants.HTTP_METHOD); // guard against multiple calls
- }
+
+ HttpMethod httpMethod = (HttpMethod) msgContext.getProperty(HTTPConstants.HTTP_METHOD);
+ if (httpMethod != null) {
+ // TODO : Don't do this if we're not on the right thread! Can we confirm?
+ log.trace("cleanup() releasing connection for " + httpMethod);
+
+ httpMethod.releaseConnection();
+ msgContext.removeProperty(HTTPConstants.HTTP_METHOD); // guard against multiple calls
+ }
}
public void init(ConfigurationContext confContext,
TransportOutDescription transportOut) throws AxisFault {
this.transportOut = transportOut;
+ //Set HTTP client version
+ setHTTPClientVersion(confContext);
// <parameter name="PROTOCOL">HTTP/1.0</parameter> or
// <parameter name="PROTOCOL">HTTP/1.1</parameter> is
@@ -376,7 +381,7 @@ public class CommonsHTTPTransportSender
// select the Message Sender depending on the REST status
AbstractHTTPSender sender;
- sender = new HTTPSender();
+ sender = new HTTPSenderImpl();
boolean chunked;
if (messageContext.getProperty(HTTPConstants.CHUNKED) != null) {
@@ -403,10 +408,7 @@ public class CommonsHTTPTransportSender
} catch (MalformedURLException e) {
log.debug(e);
throw AxisFault.makeFault(e);
- } catch (HttpException e) {
- log.debug(e);
- throw AxisFault.makeFault(e);
- } catch (IOException e) {
+ } catch (IOException e) {
log.debug(e);
throw AxisFault.makeFault(e);
}
@@ -505,4 +507,10 @@ public class CommonsHTTPTransportSender
return soapActionString;
}
+
+ public void setHTTPClientVersion(ConfigurationContext configurationContext) {
+ configurationContext.setProperty(HTTPTransportConstants.HTTP_CLIENT_VERSION,
+ HTTPTransportConstants.HTTP_CLIENT_3_X_VERSION);
+ }
+
}
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java Tue May 22 10:10:01 2012
@@ -19,30 +19,18 @@
package org.apache.axis2.transport.http;
-import org.apache.commons.httpclient.Header;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-public class CommonsTransportHeaders implements Map {
- private Header[] headers;
+public abstract class CommonsTransportHeaders implements Map {
HashMap headerMap = null;
-
- public CommonsTransportHeaders(Header[] headers) {
- this.headers = headers;
- }
-
- private void init() {
- headerMap = new HashMap();
-
- for (int i = 0; i < headers.length; i++) {
- headerMap.put(headers[i].getName(), headers[i].getValue());
- }
- }
-
+
+ protected abstract void init();
+
public int size() {
if (headerMap == null) {
init();
@@ -125,4 +113,14 @@ public class CommonsTransportHeaders imp
}
return headerMap.put(key, value);
}
+
+ public HashMap getHeaderMap() {
+ return headerMap;
+ }
+
+ public void setHeaderMap(HashMap headerMap) {
+ this.headerMap = headerMap;
+ }
+
+
}
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=1341384&r1=1341383&r2=1341384&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 Tue May 22 10:10:01 2012
@@ -23,58 +23,16 @@ package org.apache.axis2.transport.http;
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.i18n.Messages;
-import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.net.URL;
-public class HTTPSender extends AbstractHTTPSender {
+//TODO - It better if we can define these method in a interface move these into AbstractHTTPSender and get rid of this class.
+public abstract class HTTPSender extends AbstractHTTPSender {
private static final Log log = LogFactory.getLog(HTTPSender.class);
-
- public void send(MessageContext msgContext, URL url, String soapActionString)
- throws IOException {
-
- // execute the HtttpMethodBase - a connection manager can be given for
- // handle multiple
-
- String httpMethod =
- (String) msgContext.getProperty(Constants.Configuration.HTTP_METHOD);
-
- if ((httpMethod != null)) {
-
- if (Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
- this.sendViaGet(msgContext, url, soapActionString);
-
- return;
- } else if (Constants.Configuration.HTTP_METHOD_DELETE.equalsIgnoreCase(httpMethod)) {
- this.sendViaDelete(msgContext, url, soapActionString);
-
- return;
- } else if (Constants.Configuration.HTTP_METHOD_PUT.equalsIgnoreCase(httpMethod)) {
- this.sendViaPut(msgContext, url, soapActionString);
-
- return;
- }
- }
-
- this.sendViaPost(msgContext, url, soapActionString);
- }
-
/**
* Used to send a request via HTTP Get method
*
@@ -83,39 +41,9 @@ public class HTTPSender extends Abstract
* @param soapActiionString - The soapAction string of the request
* @throws AxisFault - Thrown in case an exception occurs
*/
- private void sendViaGet(MessageContext msgContext, URL url, 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) {
- 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);
- }
- }
-
- private void cleanup(MessageContext msgContext, HttpMethod method) {
- if (msgContext.isPropertyTrue(HTTPConstants.AUTO_RELEASE_CONNECTION)) {
- log.trace("AutoReleasing " + method);
- method.releaseConnection();
- }
- }
-
+ protected abstract void sendViaGet(MessageContext msgContext, URL url, String soapActiionString)
+ throws AxisFault;
+
/**
* Used to send a request via HTTP Delete Method
*
@@ -124,24 +52,8 @@ public class HTTPSender extends Abstract
* @param soapActiionString - The soapAction string of the request
* @throws AxisFault - Thrown in case an exception occurs
*/
- private void sendViaDelete(MessageContext msgContext, URL url, 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);
- }
- }
-
+ protected abstract void sendViaDelete(MessageContext msgContext, URL url, String soapActiionString)
+ throws AxisFault;
/**
* Used to send a request via HTTP Post Method
*
@@ -150,55 +62,9 @@ public class HTTPSender extends Abstract
* @param soapActionString - The soapAction string of the request
* @throws AxisFault - Thrown in case an exception occurs
*/
- private void sendViaPost(MessageContext msgContext, URL url,
- 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;
- }
-*/
+ protected abstract void sendViaPost(MessageContext msgContext, URL url,
+ String soapActionString) throws AxisFault;
- 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 AxisRequestEntity(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) {
- 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);
- }
- }
/**
* Used to send a request via HTTP Put Method
@@ -208,52 +74,10 @@ public class HTTPSender extends Abstract
* @param soapActionString - The soapAction string of the request
* @throws AxisFault - Thrown in case an exception occurs
*/
- private void sendViaPut(MessageContext msgContext, URL url,
- 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 AxisRequestEntity(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) {
- 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);
- }
- }
+ protected abstract void sendViaPut(MessageContext msgContext, URL url,
+ String soapActionString) throws AxisFault;
+
/**
* Used to handle the HTTP Response
*
@@ -261,77 +85,70 @@ public class HTTPSender extends Abstract
* @param method - The HTTP method used
* @throws IOException - Thrown in case an exception occurs
*/
- private void handleResponse(MessageContext msgContext,
- HttpMethodBase method) throws IOException {
- int statusCode = method.getStatusCode();
- HTTPStatusCodeFamily family = getHTTPStatusCodeFamily(statusCode);
- log.trace("Handling response - " + statusCode);
- if (statusCode == HttpStatus.SC_ACCEPTED) {
- /* When an HTTP 202 Accepted code has been received, this will be the case of an execution
- * of an in-only operation. In such a scenario, the HTTP response headers should be returned,
- * i.e. session cookies. */
- obtainHTTPHeaderInformation(method, msgContext);
- // Since we don't expect any content with a 202 response, we must release the connection
- method.releaseConnection();
- } else if (HTTPStatusCodeFamily.SUCCESSFUL.equals(family)) {
- // Save the HttpMethod so that we can release the connection when cleaning up
- msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
- processResponse(method, msgContext);
- } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR ||
- statusCode == HttpStatus.SC_BAD_REQUEST) {
- // Save the HttpMethod so that we can release the connection when cleaning up
- msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
- Header contenttypeHeader =
- method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
- String value = null;
- if (contenttypeHeader != null) {
- value = contenttypeHeader.getValue();
- }
- OperationContext opContext = msgContext.getOperationContext();
- if(opContext!=null){
- MessageContext inMessageContext =
- opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- if(inMessageContext!=null){
- inMessageContext.setProcessingFault(true);
- }
- }
- if (value != null) {
+ protected abstract void handleResponse(MessageContext msgContext,
+ Object httpMethodBase) throws IOException;
+
+ protected abstract void cleanup(MessageContext msgContext, Object httpMethod);
+
+
- processResponse(method, msgContext);
- }
-
- if (org.apache.axis2.util.Utils.isClientThreadNonBlockingPropertySet(msgContext)) {
- throw new AxisFault(Messages.getMessage("transportError",
- String.valueOf(statusCode),
- method.getStatusText()));
+ public void send(MessageContext msgContext, URL url, String soapActionString)
+ throws IOException {
+
+ // execute the HtttpMethodBase - a connection manager can be given for
+ // handle multiple
+
+ String httpMethod =
+ (String) msgContext.getProperty(Constants.Configuration.HTTP_METHOD);
+
+ if ((httpMethod != null)) {
+
+ if (Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
+ this.sendViaGet(msgContext, url, soapActionString);
+
+ return;
+ } else if (Constants.Configuration.HTTP_METHOD_DELETE.equalsIgnoreCase(httpMethod)) {
+ this.sendViaDelete(msgContext, url, soapActionString);
+
+ return;
+ } else if (Constants.Configuration.HTTP_METHOD_PUT.equalsIgnoreCase(httpMethod)) {
+ this.sendViaPut(msgContext, url, soapActionString);
+
+ return;
}
- } else {
- // Since we don't process the response, we must release the connection immediately
- method.releaseConnection();
- throw new AxisFault(Messages.getMessage("transportError",
- String.valueOf(statusCode),
- method.getStatusText()));
}
- }
-
+
+ this.sendViaPost(msgContext, url, soapActionString);
+ }
+
/**
- * Used to determine the family of HTTP status codes to which the given code belongs.
- *
- * @param statusCode - The HTTP status code
- */
- private HTTPStatusCodeFamily getHTTPStatusCodeFamily(int statusCode) {
- switch(statusCode/100) {
- case 1: return HTTPStatusCodeFamily.INFORMATIONAL;
- case 2: return HTTPStatusCodeFamily.SUCCESSFUL;
- case 3: return HTTPStatusCodeFamily.REDIRECTION;
- case 4: return HTTPStatusCodeFamily.CLIENT_ERROR;
- case 5: return HTTPStatusCodeFamily.SERVER_ERROR;
- default: return HTTPStatusCodeFamily.OTHER;
+ * Used to determine the family of HTTP status codes to which the given code
+ * belongs.
+ *
+ * @param statusCode
+ * - The HTTP status code
+ */
+ protected HTTPStatusCodeFamily getHTTPStatusCodeFamily(int statusCode) {
+ switch (statusCode / 100) {
+ case 1:
+ return HTTPStatusCodeFamily.INFORMATIONAL;
+ case 2:
+ return HTTPStatusCodeFamily.SUCCESSFUL;
+ case 3:
+ return HTTPStatusCodeFamily.REDIRECTION;
+ case 4:
+ return HTTPStatusCodeFamily.CLIENT_ERROR;
+ case 5:
+ return HTTPStatusCodeFamily.SERVER_ERROR;
+ default:
+ return HTTPStatusCodeFamily.OTHER;
}
}
-
/**
* The set of HTTP status code families.
*/
- private enum HTTPStatusCodeFamily {INFORMATIONAL, SUCCESSFUL, REDIRECTION, CLIENT_ERROR, SERVER_ERROR, OTHER}
+ protected enum HTTPStatusCodeFamily {
+ INFORMATIONAL, SUCCESSFUL, REDIRECTION, CLIENT_ERROR, SERVER_ERROR, OTHER
+ }
+
}
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HTTPWorker.java Tue May 22 10:10:01 2012
@@ -116,12 +116,7 @@ public class HTTPWorker implements Worke
}
}
if (HttpUtils.endsWithIgnoreCase(uri , "?wsdl2")) {
- /**
- * service name can be hierarchical (axis2/services/foo/1.0.0/Version?wsdl2) or
- * normal (axis2/services/Version?wsdl2).
- */
- String[] temp = uri.split(contextPath);
- String serviceName = temp[1].substring(0, temp[1].length() - 6);
+ String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 6);
HashMap services = configurationContext.getAxisConfiguration().getServices();
AxisService service = (AxisService) services.get(serviceName);
if (service != null) {
@@ -141,7 +136,7 @@ public class HTTPWorker implements Worke
* service name can be hierarchical (axis2/services/foo/1.0.0/Version?wsdl) or
* normal (axis2/services/Version?wsdl).
*/
- String[] temp = uri.split(contextPath);
+ String[] temp = uri.split(configurationContext.getServiceContextPath() + "/");
String serviceName = temp[1].substring(0, temp[1].length() - 5);
HashMap services = configurationContext.getAxisConfiguration().getServices();
@@ -159,12 +154,7 @@ public class HTTPWorker implements Worke
}
}
if (HttpUtils.endsWithIgnoreCase(uri , "?xsd")) {
- /**
- * service name can be hierarchical (axis2/services/foo/bar/Version) or
- * normal (axis2/services/Version).
- */
- String[] temp = uri.split(contextPath);
- String serviceName = temp[1].substring(0, temp[1].length() - 4);
+ String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 4);
HashMap services = configurationContext.getAxisConfiguration().getServices();
AxisService service = (AxisService) services.get(serviceName);
if (service != null) {
@@ -183,9 +173,8 @@ public class HTTPWorker implements Worke
if (HttpUtils.indexOfIngnoreCase(uri , "?xsd=") > 0) {
// fix for imported schemas
String[] uriParts = uri.split("[?]xsd=");
- // fix for hierarchical service names
- String[] temp = uriParts[0].split(contextPath);
- String serviceName = temp[1];
+ String serviceName =
+ uri.substring(uriParts[0].lastIndexOf("/") + 1, uriParts[0].length());
String schemaName = uri.substring(uri.lastIndexOf("=") + 1);
HashMap services = configurationContext.getAxisConfiguration().getServices();
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HttpTransportProperties.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HttpTransportProperties.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HttpTransportProperties.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/HttpTransportProperties.java Tue May 22 10:10:01 2012
@@ -19,32 +19,23 @@
package org.apache.axis2.transport.http;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.auth.AuthPolicy;
-import org.apache.commons.httpclient.auth.AuthScope;
-
-import java.util.List;
import java.util.Properties;
/**
* Utility bean for setting transport properties in runtime.
*/
-public class HttpTransportProperties {
- protected boolean chunked;
- protected HttpVersion httpVersion;
+public abstract class HttpTransportProperties {
+
+ protected boolean chunked;
protected String protocol;
-
- public HttpTransportProperties() {
- }
+
+ public abstract void setHttpVersion(Object httpVerion);
+
+ public abstract Object getHttpVersion();
public boolean getChunked() {
return chunked;
}
-
- public HttpVersion getHttpVersion() {
- return httpVersion;
- }
-
public String getProtocol() {
return protocol;
}
@@ -53,10 +44,6 @@ public class HttpTransportProperties {
this.chunked = chunked;
}
- public void setHttpVersion(HttpVersion httpVerion) {
- this.httpVersion = httpVerion;
- }
-
public void setProtocol(String protocol) {
this.protocol = protocol;
}
@@ -112,110 +99,6 @@ public class HttpTransportProperties {
}
}
- /*
- This class is responsible for holding all the necessary information needed for NTML, Digest
- and Basic Authentication. Authentication itself is handled by httpclient. User doesn't need to
- warry about what authentication mechanism it uses. Axis2 uses httpclinet's default authentication
- patterns.
- */
- public static class Authenticator {
- /*host that needed to be authenticated with*/
- private String host;
- /*port of the host that needed to be authenticated with*/
- private int port = AuthScope.ANY_PORT;
- /*Realm for authentication scope*/
- private String realm = AuthScope.ANY_REALM;
- /*Domain needed by NTCredentials for NT Domain*/
- private String domain;
- /*User for authenticate*/
- private String username;
- /*Password of the user for authenticate*/
- private String password;
- /* Switch to use preemptive authentication or not*/
- private boolean preemptive = false;
- /* if Authentication scheme needs retry just turn on the following flag */
- private boolean allowedRetry = false;
- /* Changing the priorty or adding a custom AuthPolicy*/
- private List authSchemes;
-
- /* Default Auth Schems*/
- public static final String NTLM = AuthPolicy.NTLM;
- public static final String DIGEST = AuthPolicy.DIGEST;
- public static final String BASIC = AuthPolicy.BASIC;
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getRealm() {
- return realm;
- }
-
- public void setRealm(String realm) {
- this.realm = realm;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public void setPreemptiveAuthentication(boolean preemptive) {
- this.preemptive = preemptive;
- }
-
- public boolean getPreemptiveAuthentication() {
- return this.preemptive;
- }
-
- public String getDomain() {
- return domain;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public void setAuthSchemes(List authSchemes) {
- this.authSchemes = authSchemes;
- }
-
- public List getAuthSchemes() {
- return this.authSchemes;
- }
-
- public void setAllowedRetry(boolean allowedRetry) {
- this.allowedRetry = allowedRetry;
- }
-
- public boolean isAllowedRetry() {
- return this.allowedRetry;
- }
- }
-
/**
* @deprecated org.apache.axis2.transport.http.HttpTransportProperties.MailProperties has been
* deprecated and user are encourage the use of java.util.Properties instead.
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity.java Tue May 22 10:10:01 2012
@@ -23,7 +23,6 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
-import org.apache.commons.httpclient.methods.RequestEntity;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLStreamException;
@@ -31,7 +30,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-public class RESTRequestEntity implements RequestEntity {
+public abstract class RESTRequestEntity {
private byte[] bytes;
private String charSetEnc;
private boolean chunked;
@@ -115,7 +114,7 @@ public class RESTRequestEntity implement
}
}
- public String getContentType() {
+ public String getContentTypeAsString() {
String encoding = format.getCharSetEncoding();
String contentType = format.getContentType();
if (encoding != null) {
@@ -133,4 +132,61 @@ public class RESTRequestEntity implement
public boolean isRepeatable() {
return true;
}
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ public void setBytes(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ public String getCharSetEnc() {
+ return charSetEnc;
+ }
+
+ public void setCharSetEnc(String charSetEnc) {
+ this.charSetEnc = charSetEnc;
+ }
+
+ public boolean isChunked() {
+ return chunked;
+ }
+
+ public void setChunked(boolean chunked) {
+ this.chunked = chunked;
+ }
+
+ public OMElement getElement() {
+ return element;
+ }
+
+ public void setElement(OMElement element) {
+ this.element = element;
+ }
+
+ public MessageContext getMsgCtxt() {
+ return msgCtxt;
+ }
+
+ public void setMsgCtxt(MessageContext msgCtxt) {
+ this.msgCtxt = msgCtxt;
+ }
+
+ public String getSoapActionString() {
+ return soapActionString;
+ }
+
+ public void setSoapActionString(String soapActionString) {
+ this.soapActionString = soapActionString;
+ }
+
+ public OMOutputFormat getFormat() {
+ return format;
+ }
+
+ public void setFormat(OMOutputFormat format) {
+ this.format = format;
+ }
+
}
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java?rev=1341384&r1=1341383&r2=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java Tue May 22 10:10:01 2012
@@ -19,12 +19,12 @@
package org.apache.axis2.transport.http;
-import org.apache.commons.httpclient.methods.RequestEntity;
-
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-public class RESTRequestEntity2 implements RequestEntity {
+public abstract class RESTRequestEntity2 {
private String contentType;
private String postRequestBody;
@@ -41,11 +41,29 @@ public class RESTRequestEntity2 implemen
return this.postRequestBody.getBytes().length;
}
- public String getContentType() {
+ public String getContentTypeAsString() {
return this.contentType;
}
public boolean isRepeatable() {
return true;
}
+
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public String getPostRequestBody() {
+ return postRequestBody;
+ }
+
+ public void setPostRequestBody(String postRequestBody) {
+ this.postRequestBody = postRequestBody;
+ }
+
+ public InputStream getRequestEntityContent() {
+ return new ByteArrayInputStream(this.postRequestBody.getBytes());
+ }
+
}
Copied: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java (from r1230452, axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java)
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java?p2=axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java&p1=axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java&r1=1230452&r2=1341384&rev=1341384&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient3/HTTPProxcyConfigurator.java Tue May 22 10:10:01 2012
@@ -41,6 +41,10 @@ import org.apache.commons.httpclient.aut
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+/**
+ * @deprecated use {@link HTTPProxyConfigurator}
+ */
+@Deprecated
public class HTTPProxcyConfigurator {
private static Log log = LogFactory.getLog(HTTPProxcyConfigurator.class);