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 ke...@apache.org on 2007/03/15 10:26:20 UTC

svn commit: r518539 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: builder/ client/ description/ transport/http/ transport/http/util/

Author: keithc
Date: Thu Mar 15 02:26:19 2007
New Revision: 518539

URL: http://svn.apache.org/viewvc?view=rev&rev=518539
Log:
Moving the soapVersion property to the binding. It resided in AxisService untill now but got to move it as its a binding specific property.
Removing setAppendAddressToEPR from stub (It was there to handle httpLocation property) as its better to handle it at the URLTemplating util. Sticking the httpLocation
property as a property to the operationContext.
Fixing XFormURLEncodedBuilder to handle escaping in templates
Updating UTLTemplatingUtil to deal with correct encoding mechanism depending on where the parameter appears


Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/XFormURLEncodedBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPSender.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URIEncoderDecoder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java Thu Mar 15 02:26:19 2007
@@ -130,41 +130,33 @@
                         String name =
                                 qName != null ? qName.getLocalPart() : innerElement.getName();
                         String value;
+                        OMNamespace ns = (qName == null ||
+                                qName.getNamespaceURI() == null
+                                || qName.getNamespaceURI().length() == 0) ?
+                                null : soapFactory.createOMNamespace(
+                                qName.getNamespaceURI(), null);
                         while ((value = (String) requestParameterMap.get(name)) != null) {
 
-                            OMNamespace ns = (qName == null ||
-                                    qName.getNamespaceURI() == null
-                                    || qName.getNamespaceURI().length() == 0) ?
-                                    null : soapFactory.createOMNamespace(
-                                    qName.getNamespaceURI(), null);
-                            if (value != null) {
+                            soapFactory.createOMElement(name, ns,
+                                                        bodyFirstChild).setText(value);
+                            minOccurs--;
+                        }
+                        if (minOccurs > 0) {
+                            if (nillable) {
 
+                                OMNamespace xsi = soapFactory.createOMNamespace(
+                                        Constants.URI_DEFAULT_SCHEMA_XSI,
+                                        Constants.NS_PREFIX_SCHEMA_XSI);
+                                OMAttribute omAttribute =
+                                        soapFactory.createOMAttribute("nil", xsi, "true");
                                 soapFactory.createOMElement(name, ns,
-                                                            bodyFirstChild).setText(value);
-                            } else {
-
-                                if (nillable) {
+                                                            bodyFirstChild)
+                                        .addAttribute(omAttribute);
 
-                                    OMNamespace xsi = soapFactory.createOMNamespace(
-                                            Constants.URI_DEFAULT_SCHEMA_XSI,
-                                            Constants.NS_PREFIX_SCHEMA_XSI);
-                                    OMAttribute omAttribute =
-                                            soapFactory.createOMAttribute("nil", xsi, "true");
-                                    soapFactory.createOMElement(name, ns,
-                                                                bodyFirstChild)
-                                            .addAttribute(omAttribute);
-
-                                } else {
-                                    throw new AxisFault("Required element " + qName +
-                                            " defined in the schema can not be found in the request");
-                                }
+                            } else {
+                                throw new AxisFault("Required element " + qName +
+                                        " defined in the schema can not be found in the request");
                             }
-                            minOccurs--;
-                        }
-                        if (minOccurs > 0) {
-                            throw new AxisFault("Required element " + qName +
-                                    " defined in the schema should appear atleast " +
-                                    innerElement.getMinOccurs() + "times");
                         }
                     }
                 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/XFormURLEncodedBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/XFormURLEncodedBuilder.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/XFormURLEncodedBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/XFormURLEncodedBuilder.java Thu Mar 15 02:26:19 2007
@@ -71,7 +71,12 @@
             throw new AxisFault("Cannot create DocumentElement without destination EPR");
         }
 
-        String requestURL = endpointReference.getAddress();
+        String requestURL = null;
+        try {
+            requestURL = URIEncoderDecoder.decode(endpointReference.getAddress());
+        } catch (UnsupportedEncodingException e) {
+            throw new AxisFault(e);
+        }
         try {
             requestURL = extractParametersUsingHttpLocation(templatedPath, parameterMap,
                                                             requestURL,
@@ -103,18 +108,9 @@
                                                 InputStream inputStream)
             throws AxisFault {
 
-        String queryString;
-
         if (query != null && !"".equals(query)) {
 
-            try {
-                queryString = URIEncoderDecoder.decode(query);
-            } catch (UnsupportedEncodingException e) {
-                log.error("Could not decode the query String in the HttpServletRequest");
-                throw new AxisFault("Could not decode the query String in the HttpServletRequest");
-            }
-
-            String parts[] = queryString.split(queryParamSeparator);
+            String parts[] = query.split(queryParamSeparator);
             for (int i = 0; i < parts.length; i++) {
                 int separator = parts[i].indexOf("=");
                 if (separator > 0) {
@@ -198,14 +194,22 @@
                     // get the preceding constant part from the template
                     String constantPart =
                             pathTemplate.substring(templateEndIndex + 1, templateStartIndex);
+                    constantPart = constantPart.replaceAll("\\{\\{","{");
+                    constantPart = constantPart.replaceAll("}}","}");
 
                     // get the index of the end of this template param
                     templateEndIndex = pathTemplate.indexOf("}", templateStartIndex);
+                    if ((pathTemplate.length() -1) > templateEndIndex && pathTemplate.charAt(templateEndIndex +1) == '}') {
+                        templateEndIndex = pathTemplate.indexOf("}", templateEndIndex +2);
+                    }
 
                     String parameterName =
                             pathTemplate.substring(templateStartIndex + 1, templateEndIndex);
                     // next try to find the next constant
                     templateStartIndex = pathTemplate.indexOf("{", templateEndIndex);
+                    if (pathTemplate.charAt(templateStartIndex +1) == '{') {
+                        templateStartIndex = pathTemplate.indexOf("{", templateStartIndex +2);
+                    }
 
                     int endIndexOfConstant = requestURIBuffer
                             .indexOf(constantPart, indexOfNextConstant) + constantPart.length();
@@ -220,18 +224,22 @@
                                 addParameterToMap(parameterMap, parameterName,
                                                   requestURIBuffer.substring(endIndexOfConstant,
                                                                              indexOfNextConstant));
+                                return requestURL.substring(indexOfNextConstant);
                             } else {
 
                                 addParameterToMap(parameterMap, parameterName,
                                                   requestURIBuffer.substring(
                                                           endIndexOfConstant));
+                                return "";
                             }
-                            return "";
+
                         } else {
 
                             constantPart =
                                     pathTemplate.substring(templateEndIndex + 1,
                                                            pathTemplate.length());
+                            constantPart = constantPart.replaceAll("\\{\\{","{");
+                            constantPart = constantPart.replaceAll("}}","}");
                             indexOfNextConstant =
                                     requestURIBuffer.indexOf(constantPart, endIndexOfConstant);
 
@@ -250,6 +258,8 @@
                         constantPart =
                                 pathTemplate
                                         .substring(templateEndIndex + 1, templateStartIndex);
+                        constantPart = constantPart.replaceAll("\\{\\{","{");
+                        constantPart = constantPart.replaceAll("}}","}");
 
                         indexOfNextConstant =
                                 requestURIBuffer.indexOf(constantPart, endIndexOfConstant);
@@ -271,7 +281,7 @@
                                    String paramValue)
             throws UnsupportedEncodingException {
         if (paramName.startsWith(WSDL2Constants.TEMPLATE_ENCODE_ESCAPING_CHARACTER)) {
-            parameterMap.put(paramName.substring(1), URIEncoderDecoder.decode(paramValue));
+            parameterMap.put(paramName.substring(1), paramValue);
         } else {
             parameterMap.put(paramName, paramValue);
         }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java Thu Mar 15 02:26:19 2007
@@ -28,9 +28,12 @@
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.httpclient.Header;
@@ -122,33 +125,6 @@
      */
     public void cleanup() throws AxisFault {
         _service.getAxisConfiguration().removeService(_service.getName());
-    }
-
-    /**
-     * sets the EPR in operation client. First get the available EPR from the service client
-     * and then append the addressFromBinding string to available address
-     *
-     * @param _operationClient
-     * @param addressFromBinding return existing address
-     */
-
-
-    protected String setAppendAddressToEPR(OperationClient _operationClient,
-                                           String addressFromBinding) {
-        EndpointReference toEPRFromServiceClient = _serviceClient.getOptions().getTo();
-
-        String oldAddress = toEPRFromServiceClient.getAddress();
-        String address = toEPRFromServiceClient.getAddress();
-
-        // here we assume either addressFromBinding have a '?' infront or not
-        if (addressFromBinding.charAt(0) != '?') {
-            addressFromBinding = "/" + addressFromBinding;
-        }
-
-        address += addressFromBinding;
-        toEPRFromServiceClient.setAddress(address);
-        _operationClient.getOptions().setTo(toEPRFromServiceClient);
-        return oldAddress;
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java Thu Mar 15 02:26:19 2007
@@ -83,8 +83,6 @@
         return property;
     }
 
-    //todo faults
-
     public Object getKey() {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Thu Mar 15 02:26:19 2007
@@ -67,8 +67,6 @@
 
 import javax.wsdl.*;
 import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.extensions.schema.Schema;
-import javax.wsdl.extensions.schema.SchemaImport;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.wsdl.xml.WSDLWriter;
@@ -1494,7 +1492,12 @@
         serviceBuilder.setServerSide(false);
         AxisService axisService = serviceBuilder.populateService();
         options.setTo(new EndpointReference(axisService.getEndpointName()));
-        options.setSoapVersionURI(axisService.getSoapNsUri());
+        AxisEndpoint axisEndpoint = (AxisEndpoint) axisService.getEndpoints()
+                .get(axisService.getEndpointName());
+        if (axisEndpoint != null) {
+            options.setSoapVersionURI((String) axisEndpoint.getBinding()
+                    .getProperty(WSDL2Constants.ATTR_WSOAP_VERSION));
+        }
         return axisService;
     }
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java Thu Mar 15 02:26:19 2007
@@ -97,6 +97,7 @@
                 if (inStream != null) {
                     envelope = TransportUtils.createSOAPMessage(
                             responseMessageContext);
+                    responseMessageContext.setEnvelope(envelope);
                 }
                 responseMessageContext.setEnvelope(envelope);
             }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Thu Mar 15 02:26:19 2007
@@ -21,6 +21,8 @@
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyReference;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAP11Constants;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -2023,9 +2025,8 @@
 
                 axisBinding.setType(soapBinding.getTransportURI());
 
-                String soapNamespaceURI = soapBinding.getElementType().getNamespaceURI();
-                axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, soapNamespaceURI);
-                axisService.setSoapNsUri(soapNamespaceURI);
+                axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
+                                        SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
 
                 String style = soapBinding.getStyle();
                 if (style != null) {
@@ -2037,9 +2038,8 @@
                 SOAP12Binding soapBinding = (SOAP12Binding) wsdl4jExtensibilityElement;
                 AxisBinding axisBinding = (AxisBinding) description;
 
-                String soapNamesapceURI = soapBinding.getElementType().getNamespaceURI();
-                axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, soapNamesapceURI);
-                axisService.setSoapNsUri(soapNamesapceURI);
+                axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
+                                        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
 
                 String style = soapBinding.getStyle();
                 if (style != null) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Thu Mar 15 02:26:19 2007
@@ -98,6 +98,8 @@
 
     private Map namespacemap;
 
+    private List operationNames = new ArrayList();
+
     private NamespaceMap stringBasedNamespaceMap;
 
     private boolean setupComplete = false;
@@ -126,6 +128,7 @@
             fullPath = file.getAbsolutePath();
         }
         Description description = wsdlReader.readWSDL(fullPath);
+
         DescriptionElement descriptionElement = description.toElement();
         savedTargetNamespace = descriptionElement.getTargetNamespace()
                 .toString();
@@ -196,7 +199,8 @@
             //
             // }
 
-            TypesElement typesElement = description.toElement()
+            DescriptionElement descriptionElement = description.toElement();
+            TypesElement typesElement = descriptionElement
                     .getTypesElement();
             if (typesElement != null) {
                 Schema[] schemas = typesElement.getSchemas();
@@ -283,7 +287,9 @@
         wsdlService = services[0];
         axisService.setName(wsdlService.getName().getLocalPart().toString());
         processInterface(wsdlService.getInterface());
-
+        if (isCodegen) {
+            axisService.setOperationsNameList(operationNames);
+        }
         processEndpoints();
 
     }
@@ -418,20 +424,14 @@
         String soapVersion;
         if ((soapVersion = soapBindingExtensions.getSoapVersion()) != null) {
             if (soapVersion.equals(WSDL2Constants.SOAP_VERSION_1_1)) {
-                // Might have to remove this as its a binding specific property
-                axisService.setSoapNsUri(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                 axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
                                         SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
             } else {
-                // Might have to remove this as its a binding specific property
-                axisService.setSoapNsUri(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                 axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
                                         SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
             }
         } else {
             // Set the default to soap 1.2
-            axisService.setSoapNsUri(
-                    WSDL20DefaultValueHolder.getDefaultValue(WSDL2Constants.ATTR_WSOAP_VERSION));
             axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
                                     WSDL20DefaultValueHolder.getDefaultValue(
                                             WSDL2Constants.ATTR_WSOAP_VERSION));
@@ -518,7 +518,7 @@
             }
 
             URI soapAction = soapBindingOperationExtensions.getSoapAction();
-            if (soapAction != null) {
+            if (soapAction != null && !"\"\"".equals(soapAction)) {
                 axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION,
                                                  soapAction.toString());
             }
@@ -797,18 +797,11 @@
         // copyExtensionAttributes(wsdl4jPortType.getExtensionAttributes(),
         // axisService, PORT_TYPE);
 
-        List operationNames = new ArrayList();
-
-
         InterfaceOperation[] interfaceOperations = serviceInterface
                 .getInterfaceOperations();
         for (int i = 0; i < interfaceOperations.length; i++) {
             axisService.addOperation(populateOperations(interfaceOperations[i]));
             operationNames.add(interfaceOperations[i].getName());
-        }
-
-        if (isCodegen) {
-            axisService.setOperationsNameList(operationNames);
         }
 
         Interface[] extendedInterfaces = serviceInterface.getExtendedInterfaces();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java Thu Mar 15 02:26:19 2007
@@ -91,6 +91,8 @@
     // This was taken from thye resolution of CR117 (WSDL 2.0 working group)
     // http://www.w3.org/2002/ws/desc/5/cr-issues/issues.html?view=normal#CR117
     // http://lists.w3.org/Archives/Public/www-ws-desc/2007Feb/0039.html
-    String LEGAL_CHARACTERS_IN_URL = "-._~!$&()*+,;=:@";
+    String LEGAL_CHARACTERS_IN_URL = "-._~!$&()*+,;=:@?/%";
+    String LEGAL_CHARACTERS_IN_PATH = "-._~!$'()*+,;=:@";
+    String LEGAL_CHARACTERS_IN_QUERY = "-._~!$'()*+,;=:@/?";
     String TEMPLATE_ENCODE_ESCAPING_CHARACTER = "!";
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPSender.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPSender.java Thu Mar 15 02:26:19 2007
@@ -30,6 +30,8 @@
 import org.apache.commons.httpclient.HttpMethodBase;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
 import org.apache.commons.httpclient.methods.DeleteMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URIEncoderDecoder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URIEncoderDecoder.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URIEncoderDecoder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URIEncoderDecoder.java Thu Mar 15 02:26:19 2007
@@ -108,9 +108,7 @@
             if ((ch >= 'a' && ch <= 'z')
                     || (ch >= 'A' && ch <= 'Z')
                     || (ch >= '0' && ch <= '9')
-                    || legal.indexOf(ch) > -1
-                    || (ch > 127 && !Character.isSpaceChar(ch) && !Character
-                    .isISOControl(ch))) {
+                    || legal.indexOf(ch) > -1) {
                 buf.append(ch);
             } else {
                 byte[] bytes = new String(new char[]{ch}).getBytes(encoding);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java?view=diff&rev=518539&r1=518538&r2=518539
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java Thu Mar 15 02:26:19 2007
@@ -23,11 +23,14 @@
 import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.woden.wsdl20.extensions.http.HTTPLocation;
+import org.apache.woden.wsdl20.extensions.http.HTTPLocationTemplate;
 
 import javax.xml.namespace.QName;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Iterator;
 
 
@@ -60,25 +63,39 @@
             firstElement =
                     messageContext.getEnvelope().getBody().getFirstElement().cloneOMElement();
         }
-
+        String queryParameterSeparator = (String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
+        if (queryParameterSeparator == null) {
+            queryParameterSeparator = WSDL20DefaultValueHolder.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT;
+        }
         HTTPLocation httpLocation = new HTTPLocation(rawURLString);
-        String[] localNames = httpLocation.getLocalNames();
-        String[] values = new String[localNames.length];
+        HTTPLocationTemplate[] templates = httpLocation.getTemplates();
 
-        for (int i = 0; i < localNames.length; i++) {
-            String localName = localNames[i];
-            try {
-                values[i] = URIEncoderDecoder.quoteIllegal(
-                        getOMElementValue(localName, firstElement),
-                        WSDL2Constants.LEGAL_CHARACTERS_IN_URL);
-            } catch (UnsupportedEncodingException e) {
-                throw new AxisFault("Unable to encode Query String");
+        for (int i = 0; i < templates.length; i++) {
+            HTTPLocationTemplate template = templates[i];
+            String localName = template.getName();
+            String elementValue = getOMElementValue(localName, firstElement);
+            if (template.isEncoded()) {
+                try {
+
+                    if (template.isQuery()) {
+                        template.setValue(URIEncoderDecoder.quoteIllegal(
+                                elementValue,
+                                WSDL2Constants.LEGAL_CHARACTERS_IN_QUERY.replaceAll(queryParameterSeparator, "")));
+                    } else {
+                        template.setValue(URIEncoderDecoder.quoteIllegal(
+                                elementValue,
+                                WSDL2Constants.LEGAL_CHARACTERS_IN_PATH));
+                    }
+                } catch (UnsupportedEncodingException e) {
+                    throw new AxisFault("Unable to encode Query String");
+                }
+
+            } else {
+                template.setValue(elementValue);
             }
         }
 
-        httpLocation.substitute(values);
-
-        return httpLocation.toString();
+        return httpLocation.getFormattedLocation();
     }
 
     /**
@@ -107,32 +124,37 @@
         if (firstElement != null) {
             Iterator iter = firstElement.getChildElements();
 
+            String legalCharacters = WSDL2Constants.LEGAL_CHARACTERS_IN_QUERY.replaceAll(queryParameterSeparator, "");
+
             while (iter.hasNext()) {
                 OMElement element = (OMElement) iter.next();
-                params = params + element.getLocalName() + "=" + element.getText() +
-                        queryParameterSeparator;
+                try {
+                    params = params + URIEncoderDecoder.quoteIllegal(element.getLocalName(), legalCharacters) + "=" + URIEncoderDecoder.quoteIllegal(element.getText(), legalCharacters) +
+                            queryParameterSeparator;
+                } catch (UnsupportedEncodingException e) {
+                    throw new AxisFault(e);
+                }
             }
         }
 
         if (!"".equals(params)) {
-
             int index = urlString.indexOf("?");
             if (index == -1) {
-                urlString = urlString + "?" + params.substring(0,params.length()-1);
-            }
-            else if (index == urlString.length() - 1) {
-                urlString = urlString + params.substring(0,params.length()-1);
+                urlString = urlString + "?" + params.substring(0, params.length() - 1);
+            } else if (index == urlString.length() - 1) {
+                urlString = urlString + params.substring(0, params.length() - 1);
 
             } else {
-                urlString = urlString + queryParameterSeparator + params.substring(0,params.length()-1);
+                urlString = urlString + queryParameterSeparator + params.substring(0, params.length() - 1);
             }
 
+            try {
+                return new URL(urlString);
+            } catch (MalformedURLException e) {
+                throw new AxisFault(e);
+            }
         }
-        try {
-            return new URL(urlString);
-        } catch (MalformedURLException e) {
-            throw new AxisFault("Unable to append query parameters to URL");
-        }
+        return url;
     }
 
     /**
@@ -152,9 +174,9 @@
             if (parentElement.getFirstOMChild() == null) {
                 parentElement.detach();
             }
+            return httpURLParam.getText();
         }
-
-        return httpURLParam.getText();
+        return "";
 
     }
 
@@ -172,19 +194,30 @@
     public static URL getTemplatedURL(URL targetURL, MessageContext messageContext, boolean detach)
             throws AxisFault {
 
-        String urlString = targetURL.toString();
-        String replacedQuery = "";
-        String path = "";
-        int separator = urlString.indexOf('{');
+        String httpLocation = (String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_LOCATION);
+
+//        String urlString = targetURL.toString();
+        if (httpLocation != null) {
+        String replacedQuery = httpLocation;
+        int separator = httpLocation.indexOf('{');
+            try {
 
         if (separator > 0) {
-            path = urlString.substring(0, separator - 1);
-            String query = urlString.substring(separator - 1);
+            replacedQuery = URIEncoderDecoder.quoteIllegal(
+                    URLTemplatingUtil.applyURITemplating(messageContext, httpLocation, detach),
+                    WSDL2Constants.LEGAL_CHARACTERS_IN_URL);
+
+        }
+                URI targetURI = new URI(targetURL.toString() + "/");
+                
+                URI appendedURI = targetURI.resolve(replacedQuery);
+                targetURL = appendedURI.toURL(); 
 
-            replacedQuery = URLTemplatingUtil.applyURITemplating(messageContext, query, detach);
-            try {
-                targetURL = new URL(path + replacedQuery);
             } catch (MalformedURLException e) {
+                throw new AxisFault("An error occured while trying to create request URL");
+            } catch (URISyntaxException e) {
+                throw new AxisFault("An error occured while trying to create request URL");
+            } catch (UnsupportedEncodingException e) {
                 throw new AxisFault("An error occured while trying to create request URL");
             }
         }



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