axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java
Date Tue, 22 Jun 2004 16:58:26 GMT
gdaniels    2004/06/22 09:58:26

  Modified:    java/src/org/apache/axis/deployment/wsdd WSDDConstants.java
                        WSDDOperation.java
               java/src/org/apache/axis/description OperationDesc.java
               java/src/org/apache/axis/handlers/soap
                        MustUnderstandChecker.java
               java/src/org/apache/axis/providers/java JavaProvider.java
                        RPCProvider.java
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
               java/src/org/apache/axis/wsdl/symbolTable Parameters.java
                        SymbolTable.java
               java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java
  Log:
  Improve handling of one-way operations, for JAX-RPC TCK and
  in general.  Also a couple of other minor fixes.
  
  * Add an "mep" field to the OperationDesc, which is currently
    WSDL4J's OperationType type.  This defaults to request/
    response.
  
  * Add an "mep" field to the Parameters object (which is
    very badly named, btw) so the WSDL reader can figure out
    the MEP and store it.
  
  * Add an "mep" attribute to the <operation> element in WSDD,
    which sets the OperationDesc's mep appropriately.
  
  * When writing deploy.wsdd, set the mep attribute based on
    the WSDL operation.  Don't bother writing it if it's
    request/response.
  
  * If an operation is one-way, don't bother writing <output>
    elements in the generated WSDL.
  
  * If an operation is one-way, don't bother building a SOAP
    envelope for the response in the RPCProvider.
  
  * Fix potential NPE in MustUnderstandChecker.
  
  * Improve efficiency of WSDL writing just a bit by clearing
    out the mappedTypes array in the Types object in cases
    where we've already written all the mapped types.
  
  Revision  Changes    Path
  1.35      +1 -0      ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java
  
  Index: WSDDConstants.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- WSDDConstants.java	25 May 2004 19:41:44 -0000	1.34
  +++ WSDDConstants.java	22 Jun 2004 16:58:17 -0000	1.35
  @@ -154,4 +154,5 @@
       public static final String ATTR_CLASSNAME = "classname";
       public static final String ATTR_CLASS = "class";
       public static final String ATTR_SOAPACTION = "soapAction";
  +    public static final String ATTR_MEP = "mep";
   }
  
  
  
  1.30      +5 -0      ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDOperation.java
  
  Index: WSDDOperation.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDOperation.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- WSDDOperation.java	8 Apr 2004 13:09:07 -0000	1.29
  +++ WSDDOperation.java	22 Jun 2004 16:58:18 -0000	1.30
  @@ -88,6 +88,11 @@
           if (soapAction != null) {
               desc.setSoapAction(soapAction);
           }
  +        
  +        String mepString = e.getAttribute(ATTR_MEP);
  +        if (mepString != null) {
  +            desc.setMep(mepString);
  +        }
   
           Element [] parameters = getChildElements(e, ELEM_WSDD_PARAM);
           for (int i = 0; i < parameters.length; i++) {
  
  
  
  1.40      +36 -0     ws-axis/java/src/org/apache/axis/description/OperationDesc.java
  
  Index: OperationDesc.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/description/OperationDesc.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- OperationDesc.java	8 Jun 2004 16:47:17 -0000	1.39
  +++ OperationDesc.java	22 Jun 2004 16:58:19 -0000	1.40
  @@ -21,10 +21,13 @@
   import org.apache.commons.logging.Log;
   
   import javax.xml.namespace.QName;
  +import javax.wsdl.OperationType;
   import java.io.Serializable;
   import java.lang.reflect.Method;
   import java.util.ArrayList;
   import java.util.Iterator;
  +import java.util.Map;
  +import java.util.HashMap;
   
   
   /**
  @@ -48,6 +51,15 @@
       public static final int MSG_METHOD_DOCUMENT = 4;
   
       public static final int MSG_METHOD_NONCONFORMING = -4;
  +    
  +    public static Map mepStrings = new HashMap();
  +    
  +    static {
  +        mepStrings.put("request-response", OperationType.REQUEST_RESPONSE);
  +        mepStrings.put("oneway", OperationType.ONE_WAY);
  +        mepStrings.put("solicit-response", OperationType.SOLICIT_RESPONSE);
  +        mepStrings.put("notification", OperationType.NOTIFICATION);
  +    }
   
       protected static Log log =
           LogFactory.getLog(OperationDesc.class.getName());
  @@ -89,6 +101,11 @@
   
       /** The documentation for the operation */
   	private String documentation = null;
  +    
  +    /** The MEP for this Operation - uses the WSDL4J OperationType for now
  +     * but we might want to have our own extensible enum for WSDL 2.0
  +     */ 
  +    private OperationType mep = OperationType.REQUEST_RESPONSE;
   
       /**
        * Default constructor.
  @@ -532,6 +549,25 @@
   
       public void setMessageOperationStyle(int messageOperationStyle) {
           this.messageOperationStyle = messageOperationStyle;
  +    }
  +
  +    public OperationType getMep() {
  +        return mep;
  +    }
  +
  +    public void setMep(OperationType mep) {
  +        this.mep = mep;
  +    }
  +    
  +    /**
  +     * Set the MEP using a string like "request-response"
  +     * @param mepString
  +     */ 
  +    public void setMep(String mepString) {
  +        OperationType newMep = (OperationType)mepStrings.get(mepString);
  +        if (newMep != null) {
  +            mep = newMep;
  +        }
       }
   }
   
  
  
  
  1.2       +7 -2      ws-axis/java/src/org/apache/axis/handlers/soap/MustUnderstandChecker.java
  
  Index: MustUnderstandChecker.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/handlers/soap/MustUnderstandChecker.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MustUnderstandChecker.java	20 Jun 2004 18:38:04 -0000	1.1
  +++ MustUnderstandChecker.java	22 Jun 2004 16:58:23 -0000	1.2
  @@ -19,6 +19,7 @@
   import org.apache.axis.AxisFault;
   import org.apache.axis.Constants;
   import org.apache.axis.MessageContext;
  +import org.apache.axis.Message;
   import org.apache.axis.components.logger.LogFactory;
   import org.apache.axis.handlers.BasicHandler;
   import org.apache.axis.message.SOAPEnvelope;
  @@ -52,8 +53,12 @@
           if (log.isDebugEnabled()) {
               log.debug(Messages.getMessage("semanticCheck00"));
           }
  -        SOAPEnvelope env =
  -                (SOAPEnvelope) msgContext.getCurrentMessage().getSOAPEnvelope();
  +        
  +        Message msg = msgContext.getCurrentMessage();
  +        if (msg == null)
  +            return;  // nothing to do if there's no message
  +        
  +        SOAPEnvelope env = msg.getSOAPEnvelope();
           Vector headers = null;
           if (service != null) {
               ArrayList acts = service.getActors();
  
  
  
  1.113     +28 -12    ws-axis/java/src/org/apache/axis/providers/java/JavaProvider.java
  
  Index: JavaProvider.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
  retrieving revision 1.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- JavaProvider.java	3 May 2004 20:04:09 -0000	1.112
  +++ JavaProvider.java	22 Jun 2004 16:58:23 -0000	1.113
  @@ -24,6 +24,7 @@
   import org.apache.axis.MessageContext;
   import org.apache.axis.components.logger.LogFactory;
   import org.apache.axis.description.JavaServiceDesc;
  +import org.apache.axis.description.OperationDesc;
   import org.apache.axis.enum.Scope;
   import org.apache.axis.handlers.soap.SOAPService;
   import org.apache.axis.message.SOAPEnvelope;
  @@ -38,6 +39,7 @@
   
   import javax.xml.rpc.holders.IntHolder;
   import javax.xml.rpc.server.ServiceLifecycle;
  +import javax.wsdl.OperationType;
   import java.io.Serializable;
   import java.util.ArrayList;
   import java.util.StringTokenizer;
  @@ -282,21 +284,35 @@
           try {
               serviceObject = getServiceObject(msgContext, service, clsName, scope);
   
  -            Message        resMsg  = msgContext.getResponseMessage();
  -            SOAPEnvelope   resEnv;
  +            SOAPEnvelope   resEnv = null;
   
  -            // If we didn't have a response message, make sure we set one up
  -            // with the appropriate versions of SOAP and Schema
  -            if (resMsg == null) {
  -                resEnv  = new SOAPEnvelope(msgContext.getSOAPConstants(),
  -                                           msgContext.getSchemaVersion());
  -
  -                resMsg = new Message(resEnv);
  -                msgContext.setResponseMessage( resMsg );
  +            // If there IS a response message AND this is a one-way operation,
  +            // we delete the response message here.  Note that this might
  +            // cause confusing results in some cases - i.e. nothing fails,
  +            // but your response headers don't go anywhere either.  It might
  +            // be nice if in the future there was a way to detect an error
  +            // when trying to install a response message in a MessageContext
  +            // associated with a one-way operation....
  +            OperationDesc operation = msgContext.getOperation();
  +            if (operation != null &&
  +                    operation.getMep() == OperationType.ONE_WAY) {
  +                msgContext.setResponseMessage(null);
               } else {
  -                resEnv  = resMsg.getSOAPEnvelope();
  -            }
  +                Message        resMsg  = msgContext.getResponseMessage();
   
  +                // If we didn't have a response message, make sure we set one up
  +                // with the appropriate versions of SOAP and Schema
  +                if (resMsg == null) {
  +                    resEnv  = new SOAPEnvelope(msgContext.getSOAPConstants(),
  +                                               msgContext.getSchemaVersion());
  +                    
  +                    resMsg = new Message(resEnv);
  +                    msgContext.setResponseMessage( resMsg );
  +                } else {
  +                    resEnv  = resMsg.getSOAPEnvelope();
  +                }
  +            }
  +            
               Message        reqMsg  = msgContext.getRequestMessage();
               SOAPEnvelope   reqEnv  = reqMsg.getSOAPEnvelope();
   
  
  
  
  1.117     +6 -0      ws-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
  
  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.116
  retrieving revision 1.117
  diff -u -r1.116 -r1.117
  --- RPCProvider.java	17 Jun 2004 05:10:20 -0000	1.116
  +++ RPCProvider.java	22 Jun 2004 16:58:23 -0000	1.117
  @@ -38,6 +38,7 @@
   
   import javax.xml.namespace.QName;
   import javax.xml.rpc.holders.Holder;
  +import javax.wsdl.OperationType;
   import java.lang.reflect.Method;
   import java.util.ArrayList;
   import java.util.Iterator;
  @@ -298,6 +299,11 @@
                       new String[]{methodSig, argClasses}),
                       e);
           }
  +        
  +        /** If this is a one-way operation, there is nothing more to do.
  +         */ 
  +        if (operation.getMep() == OperationType.ONE_WAY)
  +            return;
           
           /* Now put the result in the result SOAPEnvelope */
           /*************************************************/
  
  
  
  1.126     +47 -31    ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
  retrieving revision 1.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- Emitter.java	20 Jun 2004 21:26:39 -0000	1.125
  +++ Emitter.java	22 Jun 2004 16:58:25 -0000	1.126
  @@ -15,7 +15,6 @@
    */
   package org.apache.axis.wsdl.fromJava;
   
  -import com.ibm.wsdl.BindingFaultImpl;
   import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
   import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
   import com.ibm.wsdl.extensions.soap.SOAPBodyImpl;
  @@ -64,6 +63,7 @@
   import javax.wsdl.PortType;
   import javax.wsdl.Service;
   import javax.wsdl.WSDLException;
  +import javax.wsdl.OperationType;
   import javax.wsdl.extensions.ExtensibilityElement;
   import javax.wsdl.extensions.soap.SOAPAddress;
   import javax.wsdl.extensions.soap.SOAPBinding;
  @@ -784,7 +784,11 @@
                   if (standardTypes.getSerializer(mappedType) == null) { 
                       types.writeTypeForPart(mappedType, name); 
                   } 
  -            } 
  +            }
  +            
  +            // Don't bother checking for subtypes, since we already wrote
  +            // all the possibilities.
  +            types.mappedTypes = null;
           }
           
           return types;
  @@ -1073,8 +1077,10 @@
        * @throws WSDLException 
        * @throws AxisFault     
        */
  -    protected void writeMessages(
  -            Definition def, Operation oper, OperationDesc desc, BindingOperation bindingOper)
  +    protected void writeMessages(Definition def,
  +                                 Operation oper,
  +                                 OperationDesc desc,
  +                                 BindingOperation bindingOper)
               throws WSDLException, AxisFault {
   
           Input input = def.createInput();
  @@ -1091,23 +1097,25 @@
           bindingOper.getBindingInput().setName(name);
           oper.setInput(input);
           def.addMessage(msg);
  -
  -        msg = writeResponseMessage(def, desc, bindingOper);
  -
  -        Output output = def.createOutput();
  -
  -        output.setMessage(msg);
  -
  -        // Give the output element a name that matches the
  -        // message.  This is necessary for overloading.
  -        // The message QName is unique.
  -        name = msg.getQName().getLocalPart();
  -
  -        output.setName(name);
  -        bindingOper.getBindingOutput().setName(name);
  -        oper.setOutput(output);
  -        def.addMessage(msg);
  -
  +        
  +        if (desc.getMep() == OperationType.REQUEST_RESPONSE) {
  +            msg = writeResponseMessage(def, desc, bindingOper);
  +            
  +            Output output = def.createOutput();
  +            
  +            output.setMessage(msg);
  +            
  +            // Give the output element a name that matches the
  +            // message.  This is necessary for overloading.
  +            // The message QName is unique.
  +            name = msg.getQName().getLocalPart();
  +            
  +            output.setName(name);
  +            bindingOper.getBindingOutput().setName(name);
  +            oper.setOutput(output);
  +            def.addMessage(msg);
  +        }
  +        
           ArrayList exceptions = desc.getFaults();
   
           for (int i = 0; (exceptions != null) && (i < exceptions.size()); i++)
{
  @@ -1186,11 +1194,17 @@
        * @return 
        */
       protected BindingOperation writeBindingOperation(Definition def,
  -                                                     Binding binding, Operation oper, OperationDesc
desc) {
  +                                                     Binding binding,
  +                                                     Operation oper,
  +                                                     OperationDesc desc) {
   
           BindingOperation bindingOper = def.createBindingOperation();
           BindingInput bindingInput = def.createBindingInput();
  -        BindingOutput bindingOutput = def.createBindingOutput();
  +        BindingOutput bindingOutput = null;
  +        
  +        // TODO : Make this deal with all MEPs
  +        if (desc.getMep() == OperationType.REQUEST_RESPONSE)
  +            bindingOutput = def.createBindingOutput();
   
           bindingOper.setName(oper.getName());
           bindingOper.setOperation(oper);
  @@ -1231,16 +1245,18 @@
           // only when we write the Message and parts.
   
           // Add soap:body element to the binding <output> element
  -        ExtensibilityElement outputBody = null;
  -        outputBody = writeSOAPBody(desc.getReturnQName());
  -        bindingOutput.addExtensibilityElement(outputBody);
  -
  -        // add soap:headers, if any, to binding <output> element
  -        // only when we write the Message and parts.
  +        if (bindingOutput != null) {
  +            ExtensibilityElement outputBody = null;
  +            outputBody = writeSOAPBody(desc.getReturnQName());
  +            bindingOutput.addExtensibilityElement(outputBody);
  +            bindingOper.setBindingOutput(bindingOutput);
   
  -        // Add input and output to operation
  +            // add soap:headers, if any, to binding <output> element
  +            // only when we write the Message and parts.
  +        }
  +        
  +        // Add input to operation
           bindingOper.setBindingInput(bindingInput);
  -        bindingOper.setBindingOutput(bindingOutput);
   
           // Faults clause
           // Comment out the following part 
  
  
  
  1.9       +3 -0      ws-axis/java/src/org/apache/axis/wsdl/symbolTable/Parameters.java
  
  Index: Parameters.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/Parameters.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Parameters.java	25 Feb 2004 14:02:50 -0000	1.8
  +++ Parameters.java	22 Jun 2004 16:58:25 -0000	1.9
  @@ -15,6 +15,7 @@
    */
   package org.apache.axis.wsdl.symbolTable;
   
  +import javax.wsdl.OperationType;
   import java.util.Map;
   import java.util.Vector;
   
  @@ -22,6 +23,8 @@
    * This class simply collects all the parameter or message data for an operation into one
place.
    */
   public class Parameters {
  +    /** The MEP for this operation (default is request-response) */
  +    public OperationType mep = OperationType.REQUEST_RESPONSE;
   
       // This vector contains instances of the Parameter class
   
  
  
  
  1.100     +5 -6      ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- SymbolTable.java	5 Jun 2004 11:05:49 -0000	1.99
  +++ SymbolTable.java	22 Jun 2004 16:58:25 -0000	1.100
  @@ -1653,11 +1653,14 @@
           if ((parameterOrder != null) && parameterOrder.isEmpty()) {
               parameterOrder = null;
           }
  +
  +        Input input = operation.getInput();
  +        Output output = operation.getOutput();
  +        
  +        parameters.mep = operation.getStyle();
           
           // All input parts MUST be in the parameterOrder list.  It is an error otherwise.
           if (parameterOrder != null && !wrapped) {
  -            Input input = operation.getInput();
  -
               if (input != null) {
                   Message inputMsg = input.getMessage();
                   Map allInputs = inputMsg.getParts();
  @@ -1682,8 +1685,6 @@
           }
   
           // Collect all the input parameters
  -        Input input = operation.getInput();
  -
           if ((input != null) && (input.getMessage() != null)) {
               getParametersFromParts(inputs,
                       input.getMessage().getOrderedParts(null),
  @@ -1692,8 +1693,6 @@
           }
   
           // Collect all the output parameters
  -        Output output = operation.getOutput();
  -
           if ((output != null) && (output.getMessage() != null)) {
               getParametersFromParts(outputs,
                       output.getMessage().getOrderedParts(null),
  
  
  
  1.85      +21 -0     ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
  
  Index: JavaDeployWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- JavaDeployWriter.java	11 May 2004 01:25:13 -0000	1.84
  +++ JavaDeployWriter.java	22 Jun 2004 16:58:26 -0000	1.85
  @@ -51,6 +51,7 @@
   import java.util.Iterator;
   import java.util.Map;
   import java.util.Vector;
  +import java.util.HashMap;
   
   /**
    * This is Wsdl2java's deploy Writer.  It writes the deploy.wsdd file.
  @@ -540,6 +541,16 @@
                       + SOAPAction
                       + "\"");
           }
  +        
  +        if (params.mep != null &&
  +                params.mep != OperationType.REQUEST_RESPONSE) {
  +            String mepString = getMepString(params.mep);
  +            if (mepString != null) {
  +                pw.print(" mep=\""
  +                         + mepString
  +                         + "\"");
  +            }
  +        }
   
           if ((params.returnParam != null) && params.returnParam.isOutHeader()) {
               pw.print(" returnHeader=\"true\"");
  @@ -650,5 +661,15 @@
           OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
   
           return new PrintWriter(writer);
  +    }
  +    
  +    public static Map mepStrings = new HashMap();
  +    static {
  +        mepStrings.put(OperationType.REQUEST_RESPONSE, "request-response");
  +        mepStrings.put(OperationType.ONE_WAY, "oneway");
  +    }
  +    
  +    String getMepString(OperationType mep) {
  +        return (String)mepStrings.get(mep);
       }
   }    // class JavaDeployWriter
  
  
  

Mime
View raw message