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 ke...@apache.org on 2007/01/22 06:20:11 UTC

svn commit: r498527 - in /webservices/axis2/branches/java/WSDL_2_0/modules: codegen/src/org/apache/axis2/wsdl/codegen/emitter/ kernel/src/org/apache/axis2/description/ kernel/src/org/apache/axis2/transport/http/

Author: keithc
Date: Sun Jan 21 21:20:09 2007
New Revision: 498527

URL: http://svn.apache.org/viewvc?view=rev&rev=498527
Log:
Added support for ignoreUncited
Added default value for queryParameterSeparator

Modified:
    webservices/axis2/branches/java/WSDL_2_0/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
    webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20DefaultValueHolder.java
    webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
    webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
    webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/RESTSender.java

Modified: webservices/axis2/branches/java/WSDL_2_0/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/WSDL_2_0/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?view=diff&rev=498527&r1=498526&r2=498527
==============================================================================
--- webservices/axis2/branches/java/WSDL_2_0/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/branches/java/WSDL_2_0/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Sun Jan 21 21:20:09 2007
@@ -1898,12 +1898,15 @@
         methodElement.appendChild(getFaultElement(doc,
                 axisOperation));
 
+        setTransferCoding(axisOperation, methodElement, doc);
+
         String mep = (String)getBindingPropertyFromOperation(WSDL2Constants.ATTR_WSOAP_MEP, axisOperation.getName());
 
         if (WSDL2Constants.URI_WSOAP_MEP.equalsIgnoreCase(mep)) {
             methodElement.appendChild(generateOptionParamComponent(doc, "org.apache.axis2.Constants.Configuration.ENABLE_REST", "true"));
             methodElement.appendChild(generateOptionParamComponent(doc," org.apache.axis2.Constants.Configuration.HTTP_METHOD", "\"" + org.apache.axis2.Constants.Configuration.HTTP_METHOD_GET + "\""));
             methodElement.appendChild(generateOptionParamComponent(doc,"org.apache.axis2.Constants.Configuration.CONTENT_TYPE", "\"" + "org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_X_WWW_FORM" + "\""));
+            methodElement.appendChild(generateOptionParamComponent(doc,"org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR", "\"" + WSDL20DefaultValueHolder.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT + "\""));
       }
 
 
@@ -1943,8 +1946,6 @@
                 }
             }
 
-
-            setTransferCoding(axisOperation, methodElement, doc);
 
             property = (String) getBindingPropertyFromOperation(WSDL2Constants.ATTR_WHTTP_CODE,
                         axisOperation.getName());

Modified: webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20DefaultValueHolder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20DefaultValueHolder.java?view=diff&rev=498527&r1=498526&r2=498527
==============================================================================
--- webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20DefaultValueHolder.java (original)
+++ webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20DefaultValueHolder.java Sun Jan 21 21:20:09 2007
@@ -24,6 +24,7 @@
 
     public static final String WHTTP_METHOD_WSDLX_SAFE = "whttp:methodWSDLsafe";
     public static final String WHTTP_METHOD_WSDLX_NOTSAFE = "whttp:methodWSDLNotsafe";
+    public static final String ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT = "&";
 
 
     static {
@@ -31,7 +32,7 @@
         defaultValuesMap.put(WSDL2Constants.ATTR_WSOAP_ACTION, "\\\"\\\"");
         defaultValuesMap.put(WHTTP_METHOD_WSDLX_SAFE, org.apache.axis2.Constants.Configuration.HTTP_METHOD_GET);
         defaultValuesMap.put(WHTTP_METHOD_WSDLX_SAFE, org.apache.axis2.Constants.Configuration.HTTP_METHOD_POST);
-        defaultValuesMap.put(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, "&");
+        defaultValuesMap.put(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT);
     }
 
     public static String getDefaultValue(String name) {

Modified: webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java?view=diff&rev=498527&r1=498526&r2=498527
==============================================================================
--- webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java (original)
+++ webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Sun Jan 21 21:20:09 2007
@@ -512,9 +512,17 @@
                         soapMep.toString());
             }
             HTTPLocation httpLocation = soapBindingOperationExtensions.getHttpLocation();
+            // If httpLocation is not null we should extract a constant part from it and add its value and the
+            // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
+            // the operation name into this map.
             if (httpLocation != null) {
-                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION,
-                        httpLocation.getLocationTemplate());
+                String httpLocationString = httpLocation.getLocationTemplate();
+                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationString);
+                axisService.addHttpLocationDispatcherString(RESTUtil.getConstantFromHTTPLocation(httpLocationString),
+                        axisOperation);
+            } else {
+                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, "/" + axisOperation.getName().
+                        getLocalPart());
             }
             axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING,
                     soapBindingOperationExtensions.getHttpTransferCodingDefault());

Modified: webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?view=diff&rev=498527&r1=498526&r2=498527
==============================================================================
--- webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Sun Jan 21 21:20:09 2007
@@ -26,6 +26,7 @@
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.WSDL20DefaultValueHolder;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.Utils;
@@ -632,43 +633,39 @@
 
              httpLocation.substitute(values);
 
-
-//            // first process the situ where user had explicitly put some params to go in the URL
-//            ArrayList httpLocationParams = (ArrayList) messageContext.getProperty(
-//                    Constants.Configuration.URL_HTTP_LOCATION_PARAMS_LIST);
-//
-//           // now let's process URL templates.
-//            String patternString = "\\{[A-Z0-9a-z._%-]+\\}";
-//            Pattern pattern = Pattern.compile(patternString);
-//
-//            StringBuffer buffer = new StringBuffer(query);
-//
-//            Matcher matcher = pattern.matcher(buffer);
-//
-//            while (matcher.find()) {
-//                String match = matcher.group();
-//
-//                // Get indices of matching string
-//                int start = matcher.start();
-//                int end = matcher.end();
-//
-//                CharSequence charSequence = match.subSequence(1, match.length() - 1);
-//
-//                buffer.delete(start, end);
-//                try {
-//                    buffer.insert(start, URLEncoder.encode(getOMElementValue(charSequence.toString(), firstElement, detach),"UTF-8"));
-//                } catch (UnsupportedEncodingException e) {
-//                    log.error("Unable to encode Query String");
-//                }
-//                matcher.reset();
-//
-//            }
-//
-//            return buffer.toString();
-
             return httpLocation.toString();
     }
 
+    protected String appendQueryParameters(MessageContext messageContext, String query) {
+
+
+        OMElement firstElement;
+        String queryParameterSeparator = (String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
+        // In case queryParameterSeparator is null we better use the default value 
+        if (queryParameterSeparator == null) {
+            queryParameterSeparator = WSDL20DefaultValueHolder.getDefaultValue(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
+        }
+        firstElement = messageContext.getEnvelope().getBody().getFirstElement();
+        ArrayList values = new ArrayList();
+        if (firstElement != null) {
+            Iterator iter = firstElement.getChildElements();
+            while(iter.hasNext()) {
+                OMElement element = (OMElement)iter.next();
+                values.add(element.getLocalName() + "=" + element.getText());
+           }
+        }
+        if (values.size() > 0) {
+            if (query == null) {
+
+            query = (String)values.get(0);
+            }
+
+            for (int i=1;i<values.size();i++) {
+                query = queryParameterSeparator + values.get(i);
+            }
+        }
+        return query;
+    }
      private String getOMElementValue(String elementName, OMElement parentElement) {
         OMElement httpURLParam = parentElement.getFirstChildWithName(new QName(elementName));
 

Modified: webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/RESTSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/RESTSender.java?view=diff&rev=498527&r1=498526&r2=498527
==============================================================================
--- webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/RESTSender.java (original)
+++ webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/transport/http/RESTSender.java Sun Jan 21 21:20:09 2007
@@ -23,8 +23,10 @@
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.transport.http.util.ComplexPart;
 import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.i18n.Messages;
 import org.apache.commons.httpclient.Header;
@@ -201,84 +203,84 @@
         }
     }
 
-    /**
-     * This will be used to support http location. User will create an OMElement to be plugged in to
-     * SOAP body. Then he has to name the parameters that should go in the url. This method will extract
-     * those parameters from the body first child and append to the url.
-     * <p/>
-     * In addition to that, user can set a URL template, like ?firstName={FirstName}. In this case,
-     * first name must be taken from the body and will replace the url.
-     *
-     * @param messageContext
-     * @param urlString
-     * @return - the URL after appending the properties
-     */
-    protected String appendParametersToURL(MessageContext messageContext, String urlString, String queryPart) {
-        StringBuffer buffer = null;
-        try {
-            OMElement firstElement = messageContext.getEnvelope().getBody().getFirstElement();
-
-            // first process the situ where user had explicitly put some params to go in the URL
-            ArrayList httpLocationParams = (ArrayList) messageContext.getProperty(
-                    Constants.Configuration.URL_HTTP_LOCATION_PARAMS_LIST);
-
-            URL url = new URL(urlString);
-            String path = url.getPath();
-
-//            if (httpLocationParams != null) {
-//                for (int i = 0; i < httpLocationParams.size(); i++) {
-//                    String httpLocationParam = (String) httpLocationParams.get(i);
-//                    OMElement httpURLParam = firstElement.getFirstChildWithName(new QName(httpLocationParam));
-//                    if (httpURLParam != null) {
-//                        path += "/" + httpURLParam.getText();
-//                        httpURLParam.detach();
-//                    }
+//    /**
+//     * This will be used to support http location. User will create an OMElement to be plugged in to
+//     * SOAP body. Then he has to name the parameters that should go in the url. This method will extract
+//     * those parameters from the body first child and append to the url.
+//     * <p/>
+//     * In addition to that, user can set a URL template, like ?firstName={FirstName}. In this case,
+//     * first name must be taken from the body and will replace the url.
+//     *
+//     * @param messageContext
+//     * @param urlString
+//     * @return - the URL after appending the properties
+//     */
+//    protected String appendParametersToURL(MessageContext messageContext, String urlString, String queryPart) {
+//        StringBuffer buffer = null;
+//        try {
+//            OMElement firstElement = messageContext.getEnvelope().getBody().getFirstElement();
+//
+//            // first process the situ where user had explicitly put some params to go in the URL
+//            ArrayList httpLocationParams = (ArrayList) messageContext.getProperty(
+//                    Constants.Configuration.URL_HTTP_LOCATION_PARAMS_LIST);
+//
+//            URL url = new URL(urlString);
+//            String path = url.getPath();
+//
+////            if (httpLocationParams != null) {
+////                for (int i = 0; i < httpLocationParams.size(); i++) {
+////                    String httpLocationParam = (String) httpLocationParams.get(i);
+////                    OMElement httpURLParam = firstElement.getFirstChildWithName(new QName(httpLocationParam));
+////                    if (httpURLParam != null) {
+////                        path += "/" + httpURLParam.getText();
+////                        httpURLParam.detach();
+////                    }
+////                }
+////            }
+//
+//            if (queryPart != null && queryPart.length() > 0) {
+//                if (queryPart.startsWith("?")) {
+//                    path = urlString + queryPart;
+//                } else {
+//                    path = urlString + "?" + queryPart;
 //                }
 //            }
-
-            if (queryPart != null && queryPart.length() > 0) {
-                if (queryPart.startsWith("?")) {
-                    path = urlString + queryPart;
-                } else {
-                    path = urlString + "?" + queryPart;
-                }
-            }
-
-            // now let's process URL templates.
-            String patternString = "\\{[A-Z0-9a-z._%-]+\\}";
-            Pattern pattern = Pattern.compile(patternString);
-
-            buffer = new StringBuffer(path);
-
-            Matcher matcher = pattern.matcher(buffer);
-
-            while (matcher.find()) {
-                String match = matcher.group();
-
-                // Get indices of matching string
-                int start = matcher.start();
-                int end = matcher.end();
-
-                CharSequence charSequence = match.subSequence(1, match.length() - 1);
-
-                buffer.delete(start, end);
-                buffer.insert(start, getOMElementValue(charSequence.toString(), firstElement));
-
-            }
-
-            return buffer.toString();
-
-
-        } catch (MalformedURLException e) {
-            log.error("Error in processing POST request", e);
-        }
-        catch (StringIndexOutOfBoundsException e) {
-            log.error("Error in processing POST request", e);
-            return buffer.toString();
-        }
-
-        return null;
-    }
+//
+//            // now let's process URL templates.
+//            String patternString = "\\{[A-Z0-9a-z._%-]+\\}";
+//            Pattern pattern = Pattern.compile(patternString);
+//
+//            buffer = new StringBuffer(path);
+//
+//            Matcher matcher = pattern.matcher(buffer);
+//
+//            while (matcher.find()) {
+//                String match = matcher.group();
+//
+//                // Get indices of matching string
+//                int start = matcher.start();
+//                int end = matcher.end();
+//
+//                CharSequence charSequence = match.subSequence(1, match.length() - 1);
+//
+//                buffer.delete(start, end);
+//                buffer.insert(start, getOMElementValue(charSequence.toString(), firstElement));
+//
+//            }
+//
+//            return buffer.toString();
+//
+//
+//        } catch (MalformedURLException e) {
+//            log.error("Error in processing POST request", e);
+//        }
+//        catch (StringIndexOutOfBoundsException e) {
+//            log.error("Error in processing POST request", e);
+//            return buffer.toString();
+//        }
+//
+//        return null;
+//    }
 
     private String getOMElementValue(String elementName, OMElement parentElement) {
         OMElement httpURLParam = parentElement.getFirstChildWithName(new QName(elementName));
@@ -293,7 +295,7 @@
     }
 
     private void sendViaGet(MessageContext msgContext, URL url)
-            throws MalformedURLException, AxisFault, IOException {
+            throws AxisFault, IOException {
         String param = getQueryParameters(msgContext);
         GetMethod getMethod = new GetMethod();
         if (isAuthenticationEnabled(msgContext)) {
@@ -310,12 +312,16 @@
             url = new URL(path + replacedQuery);
         }
 
-//        String urlString = url.getFile();
-//        urlString = appendParametersToURL(msgContext, urlString, param);
-
         getMethod.setPath(url.getPath());
-        getMethod.setQueryString(url.getQuery());
-
+        String query = url.getQuery();
+        String ignoreUncited = (String) msgContext.getProperty(WSDL2Constants.ATTR_WHTTP_IGNORE_UNCITED);
+        // If ignoreUncited property is true we can ignore the uncited parameters in the url, If it is not specified it
+        // defaults to false hence we append the additional query parameters.
+        if (ignoreUncited != null && JavaUtils.isTrueExplicitly(ignoreUncited)) {
+            getMethod.setQueryString(query);
+        } else {
+            getMethod.setQueryString(appendQueryParameters(msgContext, url.getQuery()));
+        }
         // Serialization as "application/x-www-form-urlencoded"
         String charEncoding =
                 (String) msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);



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