axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava JavaGeneratorFactory.java JavaStubWriter.java
Date Thu, 10 Oct 2002 15:12:15 GMT
butek       2002/10/10 08:12:15

  Modified:    java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
               java/src/org/apache/axis/wsdl/symbolTable FaultInfo.java
               java/src/org/apache/axis/wsdl/toJava
                        JavaGeneratorFactory.java JavaStubWriter.java
  Log:
  Some more fault/header fixes (testcase to test these fixes still to come...)
  - added a little defensiveness to FaultInfo
  - now that we have FaultInfo, we should use it (ie, JavaGeneratorFactory,
  JavaStubWriter) so we make sure we get ALL info (like implicit header faults)
  - now that faults are determined (wrongly, in my opinion) from the binding
  instead of the portType, it exposed a problem in Java2WSDL.  It was
  generating WSDL that had a portType fault clause but no corresponding
  binding fault clause.  Before the new fault fixes, test/wsdl/roundtrip was
  generating an SEI with exceptions on the methods.  After the fault fixes
  the SEI had no exceptions.  The test still passed because the exception
  aspect wasn't being tested (probably something else I should change).
  
  Revision  Changes    Path
  1.13      +1 -0      xml-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- resource.properties	9 Oct 2002 19:06:31 -0000	1.12
  +++ resource.properties	10 Oct 2002 15:12:15 -0000	1.13
  @@ -1036,3 +1036,4 @@
   missingSoapFault00=ERROR: Missing <soap:fault> element inFault "{0}" in operation
"{0}", in binding {1}
   expectedHeaderParam=Found instance data for {0} in the soap:body instead of the soap:header.
   noReturnParam=Didn''t find specified return QName {0}!
  +noMsg=No symbol table entry found for message {0}
  
  
  
  1.69      +36 -1     xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- Emitter.java	30 Sep 2002 03:36:06 -0000	1.68
  +++ Emitter.java	10 Oct 2002 15:12:15 -0000	1.69
  @@ -58,6 +58,7 @@
   import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
   import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
   import com.ibm.wsdl.extensions.soap.SOAPBodyImpl;
  +import com.ibm.wsdl.extensions.soap.SOAPFaultImpl;
   import com.ibm.wsdl.extensions.soap.SOAPOperationImpl;
   
   import org.apache.axis.AxisFault;
  @@ -74,6 +75,7 @@
   import org.w3c.dom.Document;
   
   import javax.wsdl.Binding;
  +import javax.wsdl.BindingFault;
   import javax.wsdl.BindingInput;
   import javax.wsdl.BindingOperation;
   import javax.wsdl.BindingOutput;
  @@ -95,6 +97,7 @@
   import javax.wsdl.extensions.soap.SOAPAddress;
   import javax.wsdl.extensions.soap.SOAPBinding;
   import javax.wsdl.extensions.soap.SOAPBody;
  +import javax.wsdl.extensions.soap.SOAPFault;
   import javax.wsdl.extensions.soap.SOAPOperation;
   
   import javax.wsdl.factory.WSDLFactory;
  @@ -801,10 +804,22 @@
           for (int i = 0; exceptions != null && i < exceptions.size(); i++) {
               FaultDesc faultDesc = (FaultDesc) exceptions.get(i);
               msg = writeFaultMessage(def, faultDesc);
  +
  +            // Add the fault to the portType
               Fault fault = def.createFault();
               fault.setMessage(msg);
  -            fault.setName((faultDesc).getName());
  +            fault.setName(faultDesc.getName());
               oper.addFault(fault);
  +
  +            // Add the fault to the binding
  +            BindingFault bFault = def.createBindingFault();
  +            bFault.setName(faultDesc.getName());
  +            SOAPFault soapFault = writeSOAPFault(desc.getElementQName(),
  +                    faultDesc.getName());
  +            bFault.addExtensibilityElement(soapFault);
  +            bindingOper.addBindingFault(bFault);
  +            
  +            // Add the fault message
               if (def.getMessage(msg.getQName()) == null) {
                   def.addMessage(msg);
               }
  @@ -921,6 +936,26 @@
           }
           return soapBody;
       } // writeSOAPBody
  +
  +    private SOAPFault writeSOAPFault(QName operQName, String faultName) {
  +        SOAPFault soapFault = new SOAPFaultImpl();
  +        if (mode == MODE_RPC) {
  +            soapFault.setUse("encoded");
  +            soapFault.setEncodingStyles(encodingList);
  +        } else {
  +            soapFault.setUse("literal");
  +        }
  +        if (targetService == null)
  +            soapFault.setNamespaceURI(intfNS);
  +        else
  +            soapFault.setNamespaceURI(targetService);
  +        if (operQName != null &&
  +            !operQName.getNamespaceURI().equals("")) {
  +            soapFault.setNamespaceURI(operQName.getNamespaceURI());
  +        }
  +        soapFault.setName(faultName);
  +        return soapFault;
  +    } // writeSOAPFault
   
       /** Create a Request Message
        *
  
  
  
  1.2       +13 -4     xml-axis/java/src/org/apache/axis/wsdl/symbolTable/FaultInfo.java
  
  Index: FaultInfo.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/FaultInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FaultInfo.java	9 Oct 2002 20:51:27 -0000	1.1
  +++ FaultInfo.java	10 Oct 2002 15:12:15 -0000	1.2
  @@ -54,6 +54,8 @@
    */
   package org.apache.axis.wsdl.symbolTable;
   
  +import java.io.IOException;
  +
   import java.util.Map;
   
   import javax.wsdl.extensions.soap.SOAPHeaderFault;
  @@ -66,6 +68,8 @@
   
   import org.apache.axis.enum.Use;
   
  +import org.apache.axis.utils.Messages;
  +
   /**
   * Fault information object.  This should probably really be FaultEntry and
   * it should be a subclass of SymTabEntry, but faults aren't first-class
  @@ -110,9 +114,14 @@
       /**
        * This constructor creates FaultInfo for a soap:headerFault.
        */
  -    public FaultInfo(SOAPHeaderFault fault, SymbolTable symbolTable) {
  -        this.message = symbolTable.getMessageEntry(fault.getMessage()).
  -                getMessage();
  +    public FaultInfo(SOAPHeaderFault fault, SymbolTable symbolTable)
  +            throws IOException {
  +        MessageEntry mEntry = symbolTable.getMessageEntry(fault.getMessage());
  +        if (mEntry == null) {
  +            throw new IOException(Messages.getMessage("noMsg",
  +                    fault.getMessage().toString()));
  +        }
  +        this.message = mEntry.getMessage();
           Part part    = message.getPart(fault.getPart());
           this.xmlType = getFaultType(symbolTable, part);
           this.use     = Use.getUse(fault.getUse());
  @@ -159,7 +168,7 @@
        * Convenience method for getting the local part of the QName.
        */
        public String getName() {
  -         return qName.getLocalPart();
  +         return qName == null ? null : qName.getLocalPart();
        } // getName
   
       /**
  
  
  
  1.29      +12 -20    xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java
  
  Index: JavaGeneratorFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- JavaGeneratorFactory.java	9 Oct 2002 20:51:30 -0000	1.28
  +++ JavaGeneratorFactory.java	10 Oct 2002 15:12:15 -0000	1.29
  @@ -58,6 +58,7 @@
   
   import java.io.IOException;
   
  +import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.Iterator;
  @@ -87,6 +88,7 @@
   import org.apache.axis.wsdl.symbolTable.BaseTypeMapping;
   import org.apache.axis.wsdl.symbolTable.BindingEntry;
   import org.apache.axis.wsdl.symbolTable.Element;
  +import org.apache.axis.wsdl.symbolTable.FaultInfo;
   import org.apache.axis.wsdl.symbolTable.MessageEntry;
   import org.apache.axis.wsdl.symbolTable.Parameter;
   import org.apache.axis.wsdl.symbolTable.Parameters;
  @@ -441,24 +443,14 @@
                   // Inspect each BindingEntry in the Symbol Table
                   if (entry instanceof BindingEntry) {
                       BindingEntry bEntry = (BindingEntry) entry;
  -                    Binding binding = bEntry.getBinding();
  -                    // Get the associated PortType
  -                    PortTypeEntry ptEntry = 
  -                        symbolTable.getPortTypeEntry(
  -                            binding.getPortType().getQName());
  -                    PortType portType = ptEntry.getPortType();
  -                    Iterator operations = portType.getOperations().iterator();
  -                    // Inspect the Operations of the PortType
  -                    while(operations.hasNext()) {
  -                        Operation operation = (Operation) operations.next();
  -                        // Get the associated parameters of the operation.
  -                        Parameters parameters = bEntry.getParameters(operation);
  -
  -                        // Inspect the faults of the operation
  -                        Iterator iFault = parameters.faults.values().iterator();
  -                        while(iFault.hasNext()) {
  -                            Fault fault = (Fault) iFault.next();
  -                            setFaultContext(fault, symbolTable);
  +                    HashMap allOpFaults = bEntry.getFaults();
  +                    Iterator ops = allOpFaults.values().iterator();
  +                    // set the context for all faults for this binding.
  +                    while (ops.hasNext()) {
  +                        ArrayList faults = (ArrayList) ops.next();
  +                        for (int j = 0; j < faults.size(); ++j) {
  +                            FaultInfo info = (FaultInfo) faults.get(j);
  +                            setFaultContext(info, symbolTable);
                           }
                       }
                   }
  @@ -471,10 +463,10 @@
        * Helper routine for the setFaultContext method above.
        * Examines the indicated fault and sets COMPLEX_TYPE_FAULT
        * EXCEPTION_DATA_TYPE and EXCEPTION_CLASS_NAME as appropriate.
  -     * @param fault Fault to analyze
  +     * @param fault FaultInfo to analyze
        * @param symbolTable SymbolTable
        */
  -    private void setFaultContext(Fault fault,
  +    private void setFaultContext(FaultInfo fault,
                                    SymbolTable symbolTable) {
           QName faultXmlType = null;
           
  
  
  
  1.102     +1 -4      xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.101
  retrieving revision 1.102
  diff -u -r1.101 -r1.102
  --- JavaStubWriter.java	9 Oct 2002 20:51:30 -0000	1.101
  +++ JavaStubWriter.java	10 Oct 2002 15:12:15 -0000	1.102
  @@ -428,14 +428,11 @@
               // Get the Exception class name
               String className = Utils.getFullExceptionName(message, symbolTable);
               
  -            // Get the xmlType of the exception data
  -            QName xmlType = Utils.getFaultDataType(message, symbolTable);
  -            
               // output the registration API call
               pw.print("        _call.addFault(");
               pw.print( Utils.getNewQName(qname) + ", ");
               pw.print( className + ".class, ");
  -            pw.print( Utils.getNewQName(xmlType) + ", ");
  +            pw.print( Utils.getNewQName(info.getXMLType()) + ", ");
               pw.print( Utils.isFaultComplex(message, symbolTable));
               pw.println(");");
           }
  
  
  

Mime
View raw message