axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl/fromJava Emitter.java
Date Mon, 14 Oct 2002 20:01:36 GMT
tomj        2002/10/14 13:01:36

  Modified:    java/src/org/apache/axis/wsdl/fromJava Emitter.java
  Log:
  Some improvements on generating WSDL from Java for faults.
  Now we actually generate reasonable fault information for the
  Group H fault interop services.
  
  Of particular note, I added a name= attirbute to the <fault> tag in WSDD.
  This allows us to round trip various names nicely.
  
  Revision  Changes    Path
  1.73      +50 -31    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.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- Emitter.java	14 Oct 2002 17:36:19 -0000	1.72
  +++ Emitter.java	14 Oct 2002 20:01:36 -0000	1.73
  @@ -60,6 +60,7 @@
   import com.ibm.wsdl.extensions.soap.SOAPBodyImpl;
   import com.ibm.wsdl.extensions.soap.SOAPFaultImpl;
   import com.ibm.wsdl.extensions.soap.SOAPOperationImpl;
  +import com.ibm.wsdl.BindingFaultImpl;
   
   import org.apache.axis.AxisFault;
   import org.apache.axis.Constants;
  @@ -874,8 +875,7 @@
               // Add the fault to the binding
               BindingFault bFault = def.createBindingFault();
               bFault.setName(faultDesc.getName());
  -            SOAPFault soapFault = writeSOAPFault(desc.getElementQName(),
  -                    faultDesc.getName());
  +            SOAPFault soapFault = writeSOAPFault(faultDesc);
               bFault.addExtensibilityElement(soapFault);
               bindingOper.addBindingFault(bFault);
               
  @@ -968,10 +968,26 @@
           output = writeSOAPBody(desc.getReturnQName());
   
           bindingOutput.addExtensibilityElement(output);
  -
  +        
  +        // Ad input and output to operation
           bindingOper.setBindingInput(bindingInput);
           bindingOper.setBindingOutput(bindingOutput);
   
  +        // Faults clause
  +        ArrayList faultList = desc.getFaults();
  +        if (faultList != null) {
  +            for (Iterator it = faultList.iterator(); it.hasNext();) {
  +                FaultDesc faultDesc = (FaultDesc) it.next();
  +                // Get a soap:fault
  +                ExtensibilityElement soapFault = writeSOAPFault(faultDesc);
  +                // Get a wsdl:fault to put the soap:fault in
  +                BindingFault bindingFault = new BindingFaultImpl();
  +                bindingFault.setName(faultDesc.getName());
  +                bindingFault.addExtensibilityElement(soapFault);
  +                bindingOper.addBindingFault(bindingFault);
  +            }
  +        }
  +        
           binding.addBindingOperation(bindingOper);
   
           return bindingOper;
  @@ -997,26 +1013,33 @@
           return soapBody;
       } // writeSOAPBody
   
  -    private SOAPFault writeSOAPFault(QName operQName, String faultName) {
  -        SOAPFault soapFault = new SOAPFaultImpl();
  -        if (use == Use.ENCODED) {
  +    private SOAPFault writeSOAPFault(FaultDesc faultDesc) {
  +        SOAPFault soapFault = new com.ibm.wsdl.extensions.soap.SOAPFaultImpl();
  +        if (use != Use.ENCODED) {
  +            soapFault.setUse("literal");
  +            // no namespace for literal, gets it from the element
  +        } else {
               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());
  +            
  +            // Set the namespace from the fault QName if it exists
  +            // otherwise use the target (or interface) namespace
  +            QName faultQName = faultDesc.getQName();
  +            if (faultQName != null &&
  +                    !faultQName.getNamespaceURI().equals("")) {
  +                soapFault.setNamespaceURI(faultQName.getNamespaceURI());
  +            } else {
  +                if (targetService == null) {
  +                    soapFault.setNamespaceURI(intfNS);
  +                } else {
  +                    soapFault.setNamespaceURI(targetService);
  +                }
  +            }
           }
  -        soapFault.setName(faultName);
           return soapFault;
       } // writeSOAPFault
  -
  +    
  +    
       /** Create a Request Message
        *
        * @param def
  @@ -1093,21 +1116,16 @@
           throws WSDLException, AxisFault
       {
   
  -        String pkgAndClsName = exception.getName();
  +        String pkgAndClsName = exception.getClassName();
           String clsName = pkgAndClsName.substring(pkgAndClsName.lastIndexOf('.') + 1,
                                                    pkgAndClsName.length());
   
  -        // There are inconsistencies in the JSR 101 version 0.7 specification
  -        // with regards to whether the java exception class name is mapped to
  -        // the wsdl:fault name= attribute or is mapped to the wsdl:message of
  -        // the wsdl:fault message= attribute.  Currently WSDL2Java uses the
  -        // latter mapping to generate the java exception class.
  -        //
  +        // Do this to cover the complex type case with no meta data
  +        exception.setName(clsName);
  +        
           // The following code uses the class name for both the name= attribute
           // and the message= attribute.
   
  -        exception.setName(clsName);
  -
           Message msg = (Message) exceptionMsg.get(pkgAndClsName);
   
           if (msg == null) {
  @@ -1118,11 +1136,12 @@
               msg.setUndefined(false);
   
               ArrayList parameters = exception.getParameters();
  -            for (int i=0; i<parameters.size(); i++) {
  -                ParameterDesc parameter = (ParameterDesc) parameters.get(i);
  -                writePartToMessage(def, msg, true, parameter);
  +            if (parameters != null) {
  +                for (int i=0; i<parameters.size(); i++) {
  +                    ParameterDesc parameter = (ParameterDesc) parameters.get(i);
  +                    writePartToMessage(def, msg, true, parameter);
  +                }
               }
  -
               exceptionMsg.put(pkgAndClsName, msg);
           }
   
  
  
  

Mime
View raw message