You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2005/09/23 07:10:12 UTC

svn commit: r291075 - in /webservices/axis2/trunk/java: modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java xdocs/mtom-guide.html

Author: ruchithf
Date: Thu Sep 22 22:10:00 2005
New Revision: 291075

URL: http://svn.apache.org/viewcvs?rev=291075&view=rev
Log:
CommonsHTTPTransportSender updated to set the connection/socket timeouts for the GET requst and to set the static params in the init method

Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    webservices/axis2/trunk/java/xdocs/mtom-guide.html

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=291075&r1=291074&r2=291075&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 Thu Sep 22 22:10:00 2005
@@ -65,6 +65,10 @@
     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";
 
@@ -409,30 +413,11 @@
             }
         }
 
-    }
-
-    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);
-
-
-        int soTimeout = HTTPConstants.DEFAULT_SO_TIMEOUT;
-        int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
-        
+        //Get the timeout values from the configuration
         try {
-			// First try getting the SO_TIMEOUT and CONNECTION_TIMEOUT values
-			// form the static configuration
-			Parameter tempSoTimeoutParam = msgContext
+			Parameter tempSoTimeoutParam = transportOut
 					.getParameter(HTTPConstants.SO_TIMEOUT);
-			Parameter tempConnTimeoutParam = msgContext
+			Parameter tempConnTimeoutParam = transportOut
 					.getParameter(HTTPConstants.CONNECTION_TIMEOUT);
 
 			if (tempSoTimeoutParam != null) {
@@ -444,25 +429,27 @@
 				connectionTimeout = Integer
 						.parseInt((String) tempConnTimeoutParam.getValue());
 			}
-
-			// 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) {
-				connectionTimeout = tempSoTimeoutProperty.intValue();
-			}
-
-			if (tempConnTimeoutProperty != null) {
-				connectionTimeout = tempConnTimeoutProperty.intValue();
-			}
-		} catch (NumberFormatException nfe) {
+        
+        } 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 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
+        getTimoutValues(msgContext);
 		
         // SO_TIMEOUT -- timeout for blocking reads
         httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
@@ -549,6 +536,34 @@
 
     }
 
+    /**
+     * 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 getTimoutValues(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) {
+				connectionTimeout = 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();
@@ -582,6 +597,14 @@
         this.httpClient = new HttpClient();
         HostConfiguration hostConfig =
                 this.getHostConfiguration(msgContext, url);
+
+        //Get the timeout values set in the runtime
+        getTimoutValues(msgContext);
+		
+        // SO_TIMEOUT -- timeout for blocking reads
+        httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
+        // timeout for initial connection
+        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
 
         this.httpClient.executeMethod(hostConfig, getMethod);
 

Modified: webservices/axis2/trunk/java/xdocs/mtom-guide.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/mtom-guide.html?rev=291075&r1=291074&r2=291075&view=diff
==============================================================================
--- webservices/axis2/trunk/java/xdocs/mtom-guide.html (original)
+++ webservices/axis2/trunk/java/xdocs/mtom-guide.html Thu Sep 22 22:10:00 2005
@@ -23,7 +23,7 @@
     </ul>
   </li>
 </ul><p><a name="1"></a></p><h2>Introduction</h2><p>Despite the flexibility, interoperability and global acceptance of XML, there are times when serializing data into XML does not make sense. Web services users may need to transmit binary attachments of various sorts like images, drawings, xml docs, etc together with SOAP message. Such data are often in a particular binary format.<br></br>
-Traditionally, two techniques for dealing with opaque data in XML have been used;</p><ol>
+Traditionally, two techniques have been used in dealing with opaque data in XML;</p><ol>
   <li><strong> "By value"</strong>  </li>
   <blockquote>
     <p>Sending binary data by value is achieved by embedding opaque data (of course after some form of encoding) as element or attribute content of the XML component of data.
@@ -118,7 +118,7 @@
 </ul><p><source><pre>&lt;parameter name="enableMTOM" locked="xsd:false"&gt;true&lt;/parameter&gt;</pre>
 </source></p><ul>
   <ul>
-      <p>User might need to restart the server after setting this parameter.</p>
+      <p>User must restart the server after setting this parameter.</p>
   </ul>
 </ul><p><a name="24"></a></p><h2>Accessing received Binary Data</h2><ul>
   <li><strong><a name="241"></a>Service </strong></li>