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 gd...@apache.org on 2002/10/05 07:44:35 UTC

cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava Utils.java

gdaniels    2002/10/04 22:44:35

  Modified:    java/src/org/apache/axis/wsdl/symbolTable Tag: interop4
                        Utils.java SymbolTable.java
               java/src/org/apache/axis/wsdl/toJava Tag: interop4
                        Utils.java
  Log:
  Fix obtaining fault part types, which had only been roughed in before.
  
  Move utility funcs to symbolTable.Utils, and add getFaultType(),
  which does the right thing for type="" or element="" parts.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.18.2.2  +67 -0     xml-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java,v
  retrieving revision 1.18.2.1
  retrieving revision 1.18.2.2
  diff -u -r1.18.2.1 -r1.18.2.2
  --- Utils.java	2 Oct 2002 21:43:42 -0000	1.18.2.1
  +++ Utils.java	5 Oct 2002 05:44:34 -0000	1.18.2.2
  @@ -62,9 +62,14 @@
   import javax.xml.namespace.QName;
   import javax.xml.rpc.holders.BooleanHolder;
   import javax.xml.rpc.holders.IntHolder;
  +import javax.wsdl.Fault;
  +import javax.wsdl.Part;
  +import javax.wsdl.Message;
  +import javax.wsdl.extensions.soap.SOAPFault;
   import java.util.HashSet;
   import java.util.Iterator;
   import java.util.Vector;
  +import java.util.Map;
   
   /**
    * This class contains static utility methods for the emitter.
  @@ -603,6 +608,68 @@
           
           return prefix + ":" + qname.getLocalPart() + "\" xmlns:" + prefix +
                   "=\"" + qname.getNamespaceURI();
  +    }
  +    
  +    /**
  +     * Get the XML type (QName) for a Fault - look in the (single) fault
  +     * part for type="" or element="" - if type, return the QName.  If
  +     * element, return the reference type for the element.
  +     * 
  +     * @param fault the Fault to dig into
  +     * @param st the SymbolTable we're using
  +     * @return the XML type of the Fault's part, or null
  +     */ 
  +    public static QName getFaultType(Fault fault, SymbolTable st) {
  +        Part part = getFaultPart(fault);
  +        if (part != null) {
  +            if (part.getTypeName() != null) {
  +                return part.getTypeName();
  +            }
  +            // Literal, so get the element's type
  +            TypeEntry entry = st.getElement(part.getElementName());
  +            if (entry != null) {
  +                return entry.getRefType().getQName();
  +            }
  +        }
  +        return null;
  +    }
  +
  +    /**
  +     * Return the QName of a fault
  +     * 
  +     * Can return null if no parts in fault
  +     */ 
  +    public static QName getFaultQName(Fault fault, SOAPFault soapFault) {
  +        Part part = getFaultPart(fault);
  +        
  +        if (part == null) return null;
  +        
  +        // Someone should have already made sure that
  +        // if use=literal, no use of namespace on the soap:fault
  +        // if use=encoded, no use of element on the part
  +        if (part.getTypeName() != null) {
  +            String namespace = soapFault.getNamespaceURI();
  +            // Now make a QName
  +            return new QName(namespace, part.getName());
  +        } else {
  +            // Use the element's QName for the fault
  +            return part.getElementName();
  +        }
  +    }
  +
  +    private static Part getFaultPart(Fault fault) {
  +        // get the name of the part - there can be only one!
  +        Message message = fault.getMessage();
  +        Map parts = message.getParts();
  +        // If no parts, skip it
  +        if (parts.size() == 0) {
  +            return null;
  +        }
  +                
  +        // We have 2 cases
  +        // - part is an element, use element name and namespace
  +        // - part is a type, use part name and binding namespace 
  +        return (Part) parts.values().iterator().next();
       }
   }
   
  
  
  
  1.41.4.3  +1 -3      xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
  retrieving revision 1.41.4.2
  retrieving revision 1.41.4.3
  diff -u -r1.41.4.2 -r1.41.4.3
  --- SymbolTable.java	5 Oct 2002 05:26:07 -0000	1.41.4.2
  +++ SymbolTable.java	5 Oct 2002 05:44:34 -0000	1.41.4.3
  @@ -1626,9 +1626,7 @@
                                             binding.getQName().toString()}));
                       }
                       
  -                    // FIXME
  -                    Part p = (Part)(opFault.getMessage().getParts().values().iterator().next());
  -                    QName xmlType = p.getTypeName();
  +                    QName xmlType = Utils.getFaultType(opFault, this);
                       
                       // put the updated entry back in the map
                       faults.add(new JavaDefinitionWriter.FaultInfo(opFault, 
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.58.4.3  +1 -32     xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
  retrieving revision 1.58.4.2
  retrieving revision 1.58.4.3
  diff -u -r1.58.4.2 -r1.58.4.3
  --- Utils.java	4 Oct 2002 23:36:02 -0000	1.58.4.2
  +++ Utils.java	5 Oct 2002 05:44:35 -0000	1.58.4.3
  @@ -273,37 +273,6 @@
       } // isFaultComplex
   
       /**
  -     * Return the QName of a fault
  -     * 
  -     * Can return null if no parts in fault
  -     */ 
  -    public static QName getFaultQName(Fault fault, SOAPFault soapFault) {
  -        // get the name of the part - there can be only one!
  -        Message message = fault.getMessage();
  -        Map parts = message.getParts();
  -        // If no parts, skip it
  -        if (parts.size() == 0) {
  -            return null;
  -        }
  -                
  -        // We have 2 cases
  -        // - part is an element, use element name and namespace
  -        // - part is a type, use part name and binding namespace 
  -        Part part = (Part) parts.values().iterator().next();
  -                
  -        // Someone should have already made sure that
  -        // if use=literal, no use of namespace on the soap:fault
  -        // if use=encoded, no use of element on the part
  -        if (part.getTypeName() != null) {
  -            String namespace = soapFault.getNamespaceURI();
  -            // Now make a QName
  -            return new QName(namespace, part.getName());
  -        } else {
  -            // Use the element's QName for the fault
  -            return part.getElementName();
  -        }
  -    }
  -    /**
        * If the specified node represents a supported JAX-RPC enumeration,
        * a Vector is returned which contains the base type and the enumeration values.
        * The first element in the vector is the base type (an TypeEntry).
  @@ -735,7 +704,7 @@
   
       /**
        * Given a MIME type, return the AXIS-specific type QName.
  -     * @param the MIME type name
  +     * @param mimeName the MIME type name
        * @return the AXIS-specific QName for the MIME type
        */
       public static QName getMIMETypeQName(String mimeName) {