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 th...@apache.org on 2007/02/08 14:49:06 UTC

svn commit: r504895 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport: MessageFormatter.java http/SOAPMessageFormatter.java http/SOAPOverHTTPSender.java

Author: thilina
Date: Thu Feb  8 05:49:06 2007
New Revision: 504895

URL: http://svn.apache.org/viewvc?view=rev&rev=504895
Log:
Applying the patch given at https://issues.apache.org/jira/browse/AXIS2-2050
Thanx isuru

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/MessageFormatter.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPMessageFormatter.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/MessageFormatter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/MessageFormatter.java?view=diff&rev=504895&r1=504894&r2=504895
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/MessageFormatter.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/MessageFormatter.java Thu Feb  8 05:49:06 2007
@@ -77,7 +77,7 @@
 	 * @return the target URL
 	 */
 	public URL getTargetAddress(MessageContext messageContext, OMOutputFormat format,
-			URL targetURL);
+			URL targetURL) throws AxisFault;
 
 	/**
 	 * @return this only if you want set a transport header for SOAP Action

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPMessageFormatter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPMessageFormatter.java?view=diff&rev=504895&r1=504894&r2=504895
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPMessageFormatter.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPMessageFormatter.java Thu Feb  8 05:49:06 2007
@@ -126,7 +126,7 @@
 	}
 
 	public URL getTargetAddress(MessageContext msgCtxt, OMOutputFormat format,
-			URL targetURL) {
+			URL targetURL) throws AxisFault{
 		// SOAP do not want to alter the target URL
 		return targetURL;
 	}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java?view=diff&rev=504895&r1=504894&r2=504895
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java Thu Feb  8 05:49:06 2007
@@ -16,6 +16,7 @@
 
 package org.apache.axis2.transport.http;
 
+
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
@@ -30,6 +31,7 @@
 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.GetMethod;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -40,9 +42,66 @@
 
     public void send(MessageContext msgContext, OMElement dataout, URL url, String soapActionString)
             throws MalformedURLException, AxisFault, 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)
+                && Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
+            this.sendViaGet(msgContext, url, soapActionString);
+
+            return;
+        }
+        this.sendViaPost(msgContext, dataout, url, soapActionString);
+    }
+
+    private void sendViaGet(MessageContext msgContext, URL url, String soapActiionString) throws IOException {
+
+        GetMethod getMethod = new GetMethod();
+        if (isAuthenticationEnabled(msgContext)) {
+            getMethod.setDoAuthentication(true);
+        }
+
+        MessageFormatter messageFormatter = TransportUtils.getMessageFormatter(
+                msgContext);
+
+        url = messageFormatter.getTargetAddress(msgContext, format, url);
+
+        getMethod.setPath((url).getFile());
+
+        getMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, messageFormatter.getContentType(msgContext, format, soapActiionString));
+
+        HttpClient httpClient = getHttpClient(msgContext);
+
+        executeMethod(httpClient, msgContext, url, getMethod);
+
+        if (getMethod.getStatusCode() == HttpStatus.SC_OK) {
+            processResponse(getMethod, msgContext);
+        } else if (getMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
+        } 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()));
+        }
+
+    }
+
+    private void sendViaPost(MessageContext msgContext, OMElement dataout, URL url, String soapActionString) throws IOException {
+
+
         HttpClient httpClient = getHttpClient(msgContext);
 
         String charEncoding =
@@ -151,4 +210,5 @@
                                                 String.valueOf(postMethod.getStatusCode()),
                                                 postMethod.getResponseBodyAsString()));
     }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org