Author: keith
Date: Mon Dec 10 23:40:13 2007
New Revision: 10888

Log:

Adding WSRequest host object HTTP Properties to WSRequest host object



Modified:
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
      (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
      Mon Dec 10 23:40:13 2007
@@ -28,9 +28,11 @@
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.client.async.AxisCallback;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HttpTransportProperties;
 import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Function;
@@ -133,6 +135,11 @@
         String useSOAP = "true";
         String useWSA = null;
         String action = null;
+        String httpLocation = null;
+        String httpLocationIgnoreUncited = null;
+        String httpQueryParameterSeparator = "&";
+        String httpInputSerialization = null;
+        String httpContentEncoding = null;
         NativeArray optionsArray = null;
 
         WSRequestHostImpl wsRequest = checkInstance(thisObj);
@@ -213,6 +220,37 @@
                     && !(actionObject instanceof UniqueTag)) {
                 action = actionObject.toString();
             }
+
+            Object httpLocationObject = optionsArray.get("HTTPLocation", 
optionsArray);
+            if (httpLocationObject != null && !(httpLocationObject instanceof 
Undefined)
+                    && !(httpLocationObject instanceof UniqueTag)) {
+                httpLocation = httpLocationObject.toString();
+            }
+
+            Object httpLocationIgnoreUncitedObject = 
optionsArray.get("HTTPLocationIgnoreUncited", optionsArray);
+            if (httpLocationIgnoreUncitedObject != null && 
!(httpLocationIgnoreUncitedObject instanceof Undefined)
+                    && !(httpLocationIgnoreUncitedObject instanceof 
UniqueTag)) {
+                httpLocationIgnoreUncited = 
httpLocationIgnoreUncitedObject.toString();
+            }
+
+            Object httpQueryParameterSeparatorObject = 
optionsArray.get("HTTPQueryParameterSeparator", optionsArray);
+            if (httpQueryParameterSeparatorObject != null && 
!(httpQueryParameterSeparatorObject instanceof Undefined)
+                    && !(httpQueryParameterSeparatorObject instanceof 
UniqueTag)) {
+                httpQueryParameterSeparator = 
httpQueryParameterSeparatorObject.toString();
+            }
+
+            Object httpInputSerializationObject = 
optionsArray.get("HTTPInputSerialization", optionsArray);
+            if (httpInputSerializationObject != null && 
!(httpInputSerializationObject instanceof Undefined)
+                    && !(httpInputSerializationObject instanceof UniqueTag)) {
+                httpInputSerialization = 
httpInputSerializationObject.toString();
+            }
+
+            Object HTTPContentEncodingObject = 
optionsArray.get("HTTPContentEncoding", optionsArray);
+            if (HTTPContentEncodingObject != null && 
!(HTTPContentEncodingObject instanceof Undefined)
+                    && !(HTTPContentEncodingObject instanceof UniqueTag)) {
+                httpLocation = HTTPContentEncodingObject.toString();
+            }
+                        
         } else {
             throw Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
         }
@@ -235,8 +273,10 @@
                 HTTPConstants.MUTTITHREAD_HTTP_CONNECTION_MANAGER,
                 new MultiThreadedHttpConnectionManager());
 
-        Options options = getOptionsObject(httpMethod, url, username, passwd, 
useSOAP, useWSA,
-                                           action, optionsArray, wsRequest);
+        Options options = getOptionsObject(httpMethod, httpLocation, 
httpLocationIgnoreUncited,
+                                           httpQueryParameterSeparator, 
httpInputSerialization,
+                                           httpContentEncoding, url, username, 
passwd, useSOAP,
+                                           useWSA, action, optionsArray, 
wsRequest);
         wsRequest.sender.setOptions(options);
         wsRequest.responseText = null;
         wsRequest.responseXML = null;
@@ -438,7 +478,12 @@
      * Creates an Axis2 options object eother using the given individual
      * parameter or using the optionsArray.
      */
-    private static Options getOptionsObject(String httpMethod, String url, 
String username,
+    private static Options getOptionsObject(String httpMethod, String 
httpLocation,
+                                            String httpLocationIgnoreUncited,
+                                            String httpQueryParameterSeparator,
+                                            String httpInputSerialization,
+                                            String httpContentEncodingString, 
String url,
+                                            String username,
                                             String passwd, String useSOAP, 
String useWSA,
                                             String action, NativeArray 
optionsArray,
                                             WSRequestHostImpl wsRequest) 
throws AxisFault {
@@ -489,6 +534,33 @@
             }
         }
 
+        if (httpLocation != null) {
+            options.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, 
httpLocation);
+        }
+
+        if (httpLocationIgnoreUncited != null) {
+            options.setProperty(WSDL2Constants.ATTR_WHTTP_IGNORE_UNCITED,
+                                Boolean.valueOf(
+                                        
JavaUtils.isTrueExplicitly(httpLocationIgnoreUncited)));
+        }
+
+        if (httpQueryParameterSeparator != null) {
+            
options.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
+                                httpQueryParameterSeparator);
+        }
+
+        if (httpInputSerialization != null) {
+            options.setProperty(WSDL2Constants.ATTR_WHTTP_INPUT_SERIALIZATION, 
httpInputSerialization);
+            options.setProperty(Constants.Configuration.MESSAGE_TYPE, 
httpInputSerialization);
+        }
+
+        if (httpContentEncodingString != null) {
+            if ("gzip".equals(httpContentEncodingString) ||
+                    "compress".equals(httpContentEncodingString)) {
+                options.setProperty("HTTPConstants.MC_GZIP_REQUEST", "true");
+            }
+        }
+
         if ((useWSA != null)
                 && (useWSA.equalsIgnoreCase("1.0") || 
useWSA.equalsIgnoreCase("true") || useWSA
                 .equalsIgnoreCase("submission"))) {

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to