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 di...@apache.org on 2007/08/02 12:04:26 UTC

svn commit: r562061 - in /webservices/axis2/branches/java/1_3/modules: codegen/src/org/apache/axis2/wsdl/codegen/emitter/ codegen/src/org/apache/axis2/wsdl/codegen/writer/ kernel/src/org/apache/axis2/builder/ kernel/src/org/apache/axis2/description/ ke...

Author: dims
Date: Thu Aug  2 03:04:23 2007
New Revision: 562061

URL: http://svn.apache.org/viewvc?view=rev&rev=562061
Log:
Merge changes from trunk:

- Fix for UTF-16LE/BE in transport header content type instead of just
UTF-16 (Interop problem with WCF/Indigo)
- Fix for circular wsdl's. (Found during WCF/Interop testing)
- Fix for "Duplicate Global type" during xmlbeans codegen
- Fix for NPE in AxisServlet (found during trying to send soap message
from jython)
- Fix badly named method 

Original SVN revisions on trunk:
561798 / 561802 / 561847 / 561888 / 561898 / 561951


Modified:
    webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
    webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java
    webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
    webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
    webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java

Modified: webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?view=diff&rev=562061&r1=562060&r2=562061
==============================================================================
--- webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Thu Aug  2 03:04:23 2007
@@ -279,7 +279,12 @@
         
             axisBindingMessage = (AxisBindingMessage) axisBindingOperation.getChild(key);
             if (axisBindingMessage != null) {
+                try {
                 return axisBindingMessage.getEffectivePolicy();
+                } catch (RuntimeException ex){
+                    System.out.println("ERROR: Ignoring policy - " + ex.getMessage());
+                    log.error(ex.getMessage(), ex);
+                }
             }
         }
         return null;

Modified: webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java?view=diff&rev=562061&r1=562060&r2=562061
==============================================================================
--- webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java (original)
+++ webservices/axis2/branches/java/1_3/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java Thu Aug  2 03:04:23 2007
@@ -39,6 +39,7 @@
 import java.util.Map;
 import java.util.Vector;
 import java.util.ArrayList;
+import java.util.Stack;
 
 public class WSDL11Writer {
 
@@ -76,7 +77,7 @@
     public void writeWSDL(AxisService axisService, Definition definition, Map changedMap) {
         try {
             if (axisService != null) {
-                writeWSDL(definition, axisService.getName(), changedMap);
+                writeWSDL(definition, axisService.getName(), changedMap, new Stack());
             }
         } catch (Exception e) {
             throw new RuntimeException("WSDL writing failed!", e);
@@ -85,7 +86,9 @@
 
     private void writeWSDL(Definition definition,
                            String serviceName,
-                           Map changedMap) throws Exception {
+                           Map changedMap,
+                           Stack stack) throws Exception {
+        stack.push(definition);
         // first process the imports and save them.
         Map imports = definition.getImports();
         if (imports != null && (imports.size() > 0)) {
@@ -98,13 +101,16 @@
                 for (Iterator importsIter = importsVector.iterator(); importsIter.hasNext();) {
                     wsdlImport = (Import)importsIter.next();
                     wsdlName = "wsdl_" + count++ + ".wsdl";
-                    writeWSDL(wsdlImport.getDefinition(), wsdlName, changedMap);
+                    Definition innerDefinition = wsdlImport.getDefinition();
+                    if(!stack.contains(innerDefinition)) {
+                        writeWSDL(innerDefinition, wsdlName, changedMap, stack);
+                    }
                     wsdlImport.setLocationURI(wsdlName);
                 }
             }
         }
         // change the locations on the imported schemas
-        adjustWSDLSchemaLocatins(definition, changedMap);
+        adjustWSDLSchemaLocations(definition, changedMap);
         // finally save the file
         WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter();
         File outputFile = FileWriter.createClassFile(baseFolder,
@@ -148,14 +154,25 @@
         }
         out.flush();
         out.close();
+        stack.pop();
+    }
+
+    /**
+     * @deprecated  please use adjustWSDLSchemaLocations
+     * @param definition
+     * @param changedSchemaLocations
+     */
+    public void adjustWSDLSchemaLocatins(Definition definition, Map changedSchemaLocations) {
+        adjustWSDLSchemaLocations(definition, changedSchemaLocations);
     }
 
     /**
      * adjust the schema locations in the original wsdl
      *
-     * @param changedScheamLocations
+     * @param definition
+     * @param changedSchemaLocations
      */
-    public void adjustWSDLSchemaLocatins(Definition definition, Map changedScheamLocations) {
+    public void adjustWSDLSchemaLocations(Definition definition, Map changedSchemaLocations) {
         Types wsdlTypes = definition.getTypes();
         if (wsdlTypes != null) {
             List extensibilityElements = wsdlTypes.getExtensibilityElements();
@@ -165,7 +182,7 @@
                 currentObject = iter.next();
                 if (currentObject instanceof Schema) {
                     schema = (Schema)currentObject;
-                    changeLocations(schema.getElement(), changedScheamLocations);
+                    changeLocations(schema.getElement(), changedSchemaLocations);
                 }
             }
         }

Modified: webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java?view=diff&rev=562061&r1=562060&r2=562061
==============================================================================
--- webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java (original)
+++ webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java Thu Aug  2 03:04:23 2007
@@ -670,7 +670,8 @@
         if ((charsetEncodingFromXML != null)
                 && !"".equals(charsetEncodingFromXML)
                 && (charsetEncodingFromTransport != null)
-                && !charsetEncodingFromXML.equalsIgnoreCase((String) charsetEncodingFromTransport))
+                && !charsetEncodingFromXML.equalsIgnoreCase(charsetEncodingFromTransport)
+                && !isValidPair(charsetEncodingFromXML, charsetEncodingFromTransport))
         {
             String faultCode;
 
@@ -681,8 +682,27 @@
             }
 
             throw new AxisFault("Character Set Encoding from "
-                    + "transport information do not match with "
-                    + "character set encoding in the received SOAP message", faultCode);
+                    + "transport information [" + charsetEncodingFromTransport + "] does not match with "
+                    + "character set encoding in the received SOAP message [" + charsetEncodingFromXML + "]", faultCode);
         }
+    }
+
+    /**
+     * check if the pair is [UTF-16,UTF-16LE] [UTF-32, UTF-32LE],[UTF-16,UTF-16BE] [UTF-32, UTF-32BE] etc.
+     * 
+     * @param enc1
+     * @param enc2
+     * @return
+     */
+    private static boolean isValidPair(String enc1, String enc2) {
+        enc1 = enc1.toLowerCase();
+        enc2 = enc2.toLowerCase();
+        if (enc1.endsWith("be") || enc1.endsWith("le")) {
+            enc1 = enc1.substring(0, enc1.length() - 2);
+        }
+        if (enc2.endsWith("be") || enc2.endsWith("le")) {
+            enc2 = enc2.substring(0, enc2.length() - 2);
+        }
+        return enc1.equals(enc2);
     }
 }

Modified: webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?view=diff&rev=562061&r1=562060&r2=562061
==============================================================================
--- webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Thu Aug  2 03:04:23 2007
@@ -294,6 +294,12 @@
 
     private void processTypes(Definition wsdlDefinition, AxisService axisService)
             throws AxisFault {
+        processTypes(wsdlDefinition, axisService, new Stack());
+    }
+
+    private void processTypes(Definition wsdlDefinition, AxisService axisService, Stack stack)
+            throws AxisFault {
+        stack.push(wsdlDefinition);
         // process all the types in all the wsdls
         Types types = wsdlDefinition.getTypes();
         if (types != null) {
@@ -312,10 +318,14 @@
             for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
                 wsdlImport = (Import) valuesIter.next();
                 // process the types recuresiveilt
-                processTypes(wsdlImport.getDefinition(), axisService);
+                Definition innerDefinition = wsdlImport.getDefinition();
+                if(!stack.contains(innerDefinition)){
+                    processTypes(innerDefinition, axisService, stack);
             }
         }
     }
+        stack.pop();
+    }
 
     private void addDocumentation(AxisDescription axisDescription, Element documentationElement) {
         if ((documentationElement != null) && (documentationElement.getFirstChild() != null)) {
@@ -634,7 +644,7 @@
 
         // setup the schemaMap
         this.schemaMap = new HashMap();
-        populateSchemaMap(wsdl4jDefinition);
+        populateSchemaMap(wsdl4jDefinition, new Stack());
 
         setPolicyRegistryFromService(axisService);
 
@@ -650,8 +660,8 @@
      * @param definition
      */
 
-    private void populateSchemaMap(Definition definition) {
-
+    private void populateSchemaMap(Definition definition, Stack stack) {
+        stack.push(definition);
         Types types = definition.getTypes();
         Object extensibilityElement;
         if (types != null) {
@@ -673,10 +683,14 @@
             values = (Vector) iter.next();
             for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
                 wsdlImport = (Import) valuesIter.next();
-                populateSchemaMap(wsdlImport.getDefinition());
+                Definition innerDefinition = wsdlImport.getDefinition();
+                if(!stack.contains(innerDefinition)) {
+                    populateSchemaMap(innerDefinition, stack);
             }
         }
     }
+        stack.pop();
+    }
 
 
     /**
@@ -824,6 +838,19 @@
      */
 
     private PortType getPortType(QName portTypeQName, Definition definition) {
+        return getPortType(portTypeQName, definition, new Stack());
+    }
+
+    /**
+     * get the port type form all the imported documents
+     *
+     * @param portTypeQName
+     * @param definition
+     * @return portType
+     */
+
+    private PortType getPortType(QName portTypeQName, Definition definition, Stack stack) {
+        stack.push(definition);
         PortType portType = null;
         Iterator iter = definition.getImports().values().iterator();
         Vector values = null;
@@ -832,12 +859,15 @@
             values = (Vector) iter.next();
             for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
                 wsdlImport = (Import) valuesIter.next();
+                Definition innerDefinition = wsdlImport.getDefinition();
+                if(stack.contains(innerDefinition)){
                 // find the binding recursively
-                portType = getPortType(portTypeQName, wsdlImport.getDefinition());
+                    portType = getPortType(portTypeQName, innerDefinition, stack);
                 if (portType != null) {
                     break;
                 }
             }
+            }
             if (portType != null) {
                 break;
             }
@@ -847,9 +877,25 @@
             // this can be in a imported wsdl
             portType = definition.getPortType(portTypeQName);
         }
+        stack.pop();
         return portType;
     }
 
+    private Binding getBinding(QName bindingQName, Definition definition) {
+        ArrayList list = new ArrayList();
+        Binding binding = getBinding(bindingQName, definition, list);
+        if (binding == null) {
+            for(int i=0;i<list.size();i++){
+                Binding binding2 = definition.getBinding(bindingQName);
+                if(binding2 != null && binding2.getPortType() != null){
+                    binding = binding2;
+                    break;
+                }
+            }
+        }
+        return binding;
+    }
+
     /**
      * first find the binding in the given definition
      * if not found serch in the imported doucuments
@@ -859,8 +905,8 @@
      * @return binding
      */
 
-    private Binding getBinding(QName bindingQName, Definition definition) {
-
+    private Binding getBinding(QName bindingQName, Definition definition, ArrayList list) {
+        list.add(definition);
         Binding binding = null;
         //first try to find a binding in the upper inmport
         Iterator iter = definition.getImports().values().iterator();
@@ -870,20 +916,19 @@
             values = (Vector) iter.next();
             for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
                 wsdlImport = (Import) valuesIter.next();
+                Definition innerDefinition = wsdlImport.getDefinition();
+                if(!list.contains(innerDefinition)) {
                 // find the binding recursively
-                binding = getBinding(bindingQName, wsdlImport.getDefinition());
+                    binding = getBinding(bindingQName, innerDefinition, list);
                 if (binding != null) {
                     break;
                 }
             }
+            }
             if (binding != null) {
                 break;
             }
         }
-
-        if (binding == null) {
-            binding = definition.getBinding(bindingQName);
-        }
         return binding;
     }
 
@@ -2554,7 +2599,16 @@
      * @param definition
      */
     private void processPoliciesInDefintion(Definition definition) {
+        processPoliciesInDefintion(definition, new Stack());
+    }
 
+    /**
+     * Process the policy definitions
+     *
+     * @param definition
+     */
+    private void processPoliciesInDefintion(Definition definition, Stack stack) {
+        stack.push(definition);
         List extElements = definition.getExtensibilityElements();
         ExtensibilityElement extElement;
         UnknownExtensibilityElement unknown = null;
@@ -2585,10 +2639,14 @@
             values = (Vector) iter.next();
             for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
                 wsdlImport = (Import) valuesIter.next();
+                Definition innerDefinition = wsdlImport.getDefinition();
                 // find the binding recursively
-                processPoliciesInDefintion(wsdlImport.getDefinition());
+                if(!stack.contains(innerDefinition)) {
+                    processPoliciesInDefintion(innerDefinition, stack);
+                }
             }
         }
+        stack.pop();
     }
 
 

Modified: webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?view=diff&rev=562061&r1=562060&r2=562061
==============================================================================
--- webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java Thu Aug  2 03:04:23 2007
@@ -25,6 +25,7 @@
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingHelper;
@@ -308,16 +309,17 @@
     private void closeStaxBuilder(MessageContext messageContext) throws ServletException {
         if (closeReader && messageContext != null) {
             try {
-                StAXBuilder builder = (StAXBuilder) messageContext.getEnvelope().getBuilder();
+                SOAPEnvelope envelope = messageContext.getEnvelope();
+                if(envelope != null) {
+                    StAXBuilder builder = (StAXBuilder) envelope.getBuilder();
                 if (builder != null) {
                     builder.close();
                 }
+                }
             } catch (Exception e) {
-                log.debug(e);
-                throw new ServletException(e);
+                log.debug(e.toString(), e);
             }
         }
-
     }
 
     /**



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