axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/client Call.java
Date Fri, 15 Mar 2002 15:35:07 GMT
gdaniels    02/03/15 07:35:07

  Modified:    java/src/org/apache/axis/encoding XMLType.java
               java/src/org/apache/axis/utils resources.properties
               java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java
               java/samples/echo EchoServiceBindingStub.java
               java/src/org/apache/axis/client Call.java
  Log:
  Force setting returnType if parameters have been set.  This involved
  creating a "void" marker QName, XMLType.AXIS_VOID, and having
  the stub emit setReturnType(AXIS_VOID) instead of (null).
  
  Revision  Changes    Path
  1.14      +4 -1      xml-axis/java/src/org/apache/axis/encoding/XMLType.java
  
  Index: XMLType.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/XMLType.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XMLType.java	26 Jan 2002 02:40:33 -0000	1.13
  +++ XMLType.java	15 Mar 2002 15:35:07 -0000	1.14
  @@ -92,7 +92,10 @@
       public static final QName SOAP_ARRAY = Constants.SOAP_ARRAY;
   
       public static final QName SOAP_MAP = Constants.SOAP_MAP;
  -    public static final QName SOAP_ELEMENT = Constants.SOAP_ELEMENT;                  
             
  +    public static final QName SOAP_ELEMENT = Constants.SOAP_ELEMENT;
  +
  +    /** A "marker" XML type QName we use to indicate a void type. */
  +    public static final QName AXIS_VOID = new QName("http://xml.apache.org/axis", "Void");
   
       public static       QName XSD_DATE;
       
  
  
  
  1.72      +1 -0      xml-axis/java/src/org/apache/axis/utils/resources.properties
  
  Index: resources.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- resources.properties	15 Mar 2002 01:14:10 -0000	1.71
  +++ resources.properties	15 Mar 2002 15:35:07 -0000	1.72
  @@ -767,3 +767,4 @@
   typeMap03=the TypeMappingRegistry of the service, which
   typeMap04=is the reason why registration is only needed for the first call.
   mustSetStyle=must set encoding style before registering serializers
  +mustSpecifyReturnType=No returnType was specified to the Call object!  You must call setReturnType()
if you have called addParameter().
  \ No newline at end of file
  
  
  
  1.45      +1 -1      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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- JavaStubWriter.java	15 Mar 2002 01:14:11 -0000	1.44
  +++ JavaStubWriter.java	15 Mar 2002 15:35:07 -0000	1.45
  @@ -540,7 +540,7 @@
               pw.println("        call.setReturnType(" + outputType + ");");
           }
           else {
  -            pw.println("        call.setReturnType(null);");
  +            pw.println("        call.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);");
           }
   
           // SoapAction
  
  
  
  1.4       +4 -2      xml-axis/java/samples/echo/EchoServiceBindingStub.java
  
  Index: EchoServiceBindingStub.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/echo/EchoServiceBindingStub.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EchoServiceBindingStub.java	13 Mar 2002 19:50:58 -0000	1.3
  +++ EchoServiceBindingStub.java	15 Mar 2002 15:35:07 -0000	1.4
  @@ -9,6 +9,8 @@
   
   package samples.echo;
   
  +import org.apache.axis.encoding.XMLType;
  +
   import javax.xml.rpc.namespace.QName;
   
   public class EchoServiceBindingStub extends org.apache.axis.client.Stub implements samples.echo.EchoServicePortType
{
  @@ -357,7 +359,7 @@
               throw new org.apache.axis.NoEndPointException();
           }
           org.apache.axis.client.Call call = getCall();
  -        call.setReturnType(null);
  +        call.setReturnType(XMLType.AXIS_VOID);
           call.setUseSOAPAction(true);
           String methodName = (addMethodToAction) ? "echoVoid" : "";
           call.setSOAPActionURI(soapAction+methodName);
  @@ -552,7 +554,7 @@
           call.addParameter("outputString", new javax.xml.rpc.namespace.QName("http://www.w3.org/2001/XMLSchema",
"string"), javax.xml.rpc.ParameterMode.PARAM_MODE_OUT);
           call.addParameter("outputInteger", new javax.xml.rpc.namespace.QName("http://www.w3.org/2001/XMLSchema",
"int"), javax.xml.rpc.ParameterMode.PARAM_MODE_OUT);
           call.addParameter("outputFloat", new javax.xml.rpc.namespace.QName("http://www.w3.org/2001/XMLSchema",
"float"), javax.xml.rpc.ParameterMode.PARAM_MODE_OUT);
  -        call.setReturnType(null);
  +        call.setReturnType(XMLType.AXIS_VOID);
           call.setUseSOAPAction(true);
           String methodName = (addMethodToAction) ? "echoStructAsSimpleTypes" : "";
           call.setSOAPActionURI(soapAction+methodName);
  
  
  
  1.98      +57 -43    xml-axis/java/src/org/apache/axis/client/Call.java
  
  Index: Call.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- Call.java	15 Mar 2002 10:19:35 -0000	1.97
  +++ Call.java	15 Mar 2002 15:35:07 -0000	1.98
  @@ -70,6 +70,7 @@
   import org.apache.axis.encoding.Serializer;
   import org.apache.axis.encoding.TypeMappingRegistry;
   import org.apache.axis.encoding.TypeMapping;
  +import org.apache.axis.encoding.XMLType;
   import org.apache.axis.message.RPCElement;
   import org.apache.axis.message.RPCParam;
   import org.apache.axis.message.SOAPBodyElement;
  @@ -78,7 +79,7 @@
   import org.apache.axis.message.SOAPHeader;
   import org.apache.axis.transport.http.HTTPTransport;
   import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.attachments.AttachmentPart; 
  +import org.apache.axis.attachments.AttachmentPart;
   import org.apache.axis.InternalException;
   import org.apache.axis.description.OperationDesc;
   import org.apache.axis.description.ServiceDesc;
  @@ -693,12 +694,12 @@
        *
        * @param  paramQName  QName of the parameter to return
        * @return XMLType    XMLType of paramQName, or null if not found.
  -     */    
  +     */
       public QName getParameterTypeByQName(QName paramQName) {
           int i;
           if ( paramNames == null ) return( null );
   
  -        for (i = 0 ; i< paramNames.size() ; i++ ) 
  +        for (i = 0 ; i< paramNames.size() ; i++ )
               if ( ((QName)paramNames.get(i)).equals(paramQName) ) {
                   return (QName) paramTypes.get(i);
               }
  @@ -795,7 +796,7 @@
       }
   
       public void setOperation(QName portName, String opName) {
  -        if ( service == null ) 
  +        if ( service == null )
               throw new JAXRPCException( JavaUtils.getMessage("noService04") );
   
           Definition wsdlDefinition = service.getWSDLDefinition();
  @@ -835,7 +836,7 @@
           List list = port.getExtensibilityElements();
           for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
               Object obj = list.get(i);
  -            if ( obj instanceof SOAPAddress ) { 
  +            if ( obj instanceof SOAPAddress ) {
                   try {
                       SOAPAddress addr = (SOAPAddress) obj ;
                       URL         url  = new URL(addr.getLocationURI());
  @@ -858,7 +859,7 @@
           list = bop.getExtensibilityElements();
           for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
               Object obj = list.get(i);
  -            if ( obj instanceof SOAPOperation ) { 
  +            if ( obj instanceof SOAPOperation ) {
                   SOAPOperation sop    = (SOAPOperation) obj ;
                   String        action = sop.getSoapActionURI();
                   if ( action != null ) {
  @@ -884,7 +885,7 @@
                   if( obj instanceof javax.wsdl.extensions.mime.MIMEMultipartRelated){
                     javax.wsdl.extensions.mime.MIMEMultipartRelated mpr=
                     (javax.wsdl.extensions.mime.MIMEMultipartRelated) obj;
  -                  Object part= null; 
  +                  Object part= null;
                     List l=  mpr.getMIMEParts();
                     for(int j=0; l!= null && j< l.size() && part== null;
j++){
                        javax.wsdl.extensions.mime.MIMEPart mp
  @@ -892,13 +893,13 @@
                        List ll= mp.getExtensibilityElements();
                        for(int k=0; ll!= null && k< ll.size() && part==
null; k++){
                          part= ll.get(k);
  -                       if ( !(part instanceof SOAPBody)) part = null; 
  +                       if ( !(part instanceof SOAPBody)) part = null;
                        }
                     }
                     if(null != part) obj= part;
                   }
   
  -                if ( obj instanceof SOAPBody ) { 
  +                if ( obj instanceof SOAPBody ) {
                       SOAPBody sBody  = (SOAPBody) obj ;
                       list = sBody.getEncodingStyles();
                       if ( list != null && list.size() > 0 )
  @@ -931,7 +932,7 @@
   
                   if ( type == null ) {
                       type = part.getElementName();
  -                    if ( type != null ) 
  +                    if ( type != null )
                         type = new javax.wsdl.QName("java","org.w3c.dom.Element");
                       else
                         throw new JAXRPCException(
  @@ -965,7 +966,7 @@
                   javax.wsdl.QName type  = part.getTypeName();
                   if ( type == null ) {
                       type = part.getElementName();
  -                    if ( type != null ) 
  +                    if ( type != null )
                         type = new javax.wsdl.QName("java","org.w3c.dom.Element");
                       else
                         throw new JAXRPCException(
  @@ -1002,17 +1003,17 @@
       }
   
       /**
  -     * Invokes a specific operation using a synchronous request-response interaction mode.
The invoke method takes 
  -     * as parameters the object values corresponding to these defined parameter types.
Implementation of the invoke 
  -     * method must check whether the passed parameter values correspond to the number,
order and types of parameters 
  +     * Invokes a specific operation using a synchronous request-response interaction mode.
The invoke method takes
  +     * as parameters the object values corresponding to these defined parameter types.
Implementation of the invoke
  +     * method must check whether the passed parameter values correspond to the number,
order and types of parameters
        * specified in the corresponding operation specification.
        *
        * @param operationName - Name of the operation to invoke
        * @param params  - Parameters for this invocation
        *
  -     * @return the value returned from the other end. 
  +     * @return the value returned from the other end.
        *
  -     * @throws java.rmi.RemoteException - if there is any error in the remote method invocation
or if the Call 
  +     * @throws java.rmi.RemoteException - if there is any error in the remote method invocation
or if the Call
        * object is not configured properly.
        */
       public Object invoke(QName operationName, Object[] params)
  @@ -1196,9 +1197,9 @@
       /**
        * Cache of transport packages we've already added to the system
        * property.
  -     */ 
  +     */
       private static ArrayList transportPackages = null;
  -    
  +
       /** Add a package to the system protocol handler search path.  This
        * enables users to create their own URLStreamHandler classes, and thus
        * allow custom protocols to be used in Axis (typically on the client
  @@ -1224,12 +1225,12 @@
                   }
               }
           }
  -        
  +
           if (transportPackages.contains(packageName))
               return;
  -        
  +
           transportPackages.add(packageName);
  -        
  +
           StringBuffer currentPackages = new StringBuffer();
           for (Iterator i = transportPackages.iterator(); i.hasNext();) {
               String thisPackage = (String) i.next();
  @@ -1334,7 +1335,7 @@
        */
       public void setRequestMessage(Message msg) {
   
  -        if(null != attachmentParts && !attachmentParts.isEmpty()){ 
  +        if(null != attachmentParts && !attachmentParts.isEmpty()){
               try{
               org.apache.axis.attachments.Attachments attachments= msg.getAttachments();
               if(null == attachments) {
  @@ -1348,7 +1349,7 @@
                 throw  new RuntimeException(ex.getMessage());
               }
           }
  -    
  +
           msgContext.setRequestMessage(msg);
           attachmentParts.clear();
       }
  @@ -1426,15 +1427,15 @@
           TypeMappingRegistry tmr = msgContext.getTypeMappingRegistry();
   
           // If a TypeMapping is not available, add one.
  -        TypeMapping tm = (TypeMapping) tmr.getTypeMapping(encodingStyle); 
  -        TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping(); 
  +        TypeMapping tm = (TypeMapping) tmr.getTypeMapping(encodingStyle);
  +        TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
           try {
               if (tm == null || tm == defaultTM ) {
                   tm = (TypeMapping) tmr.createTypeMapping();
                   tm.setSupportedNamespaces(new String[] {encodingStyle});
                   tmr.register(encodingStyle, tm);
               }
  -            if (!force && tm.isRegistered(javaType, xmlType)) 
  +            if (!force && tm.isRegistered(javaType, xmlType))
                   return;
   
               // Register the information
  @@ -1493,16 +1494,16 @@
                       throws AxisFault {
   
           if (log.isDebugEnabled()) {
  -            log.debug(JavaUtils.getMessage("enter00", 
  +            log.debug(JavaUtils.getMessage("enter00",
                                              "Call::invoke(ns, meth, args)") );
           }
   
           RPCElement  body = new RPCElement(namespace, method, args);
  -        
  +
           Object ret = invoke( body );
   
           if (log.isDebugEnabled()) {
  -            log.debug(JavaUtils.getMessage("exit00", 
  +            log.debug(JavaUtils.getMessage("exit00",
                                              "Call::invoke(ns, meth, args)") );
           }
   
  @@ -1539,10 +1540,19 @@
        */
       public Object invoke( RPCElement body ) throws AxisFault {
           if (log.isDebugEnabled()) {
  -            log.debug(JavaUtils.getMessage("enter00", 
  +            log.debug(JavaUtils.getMessage("enter00",
                                              "Call::invoke(RPCElement)") );
           }
   
  +        /**
  +         * Since JAX-RPC requires us to specify a return type if we've set
  +         * parameter types, check for this case right now and toss a fault
  +         * if things don't look right.
  +         */
  +        if (paramTypes != null && returnType == null) {
  +            throw new AxisFault(JavaUtils.getMessage("mustSpecifyReturnType"));
  +        }
  +
           SOAPEnvelope         reqEnv = new SOAPEnvelope();
           SOAPEnvelope         resEnv = null ;
           Message              reqMsg = new Message( reqEnv );
  @@ -1587,13 +1597,13 @@
                   log.error(JavaUtils.getMessage("exception00"), e);
                   throw AxisFault.makeFault(e);
               }
  -            
  +
               if (resArgs != null && resArgs.size() > 0) {
  -                
  +
                   // If there is no return, then we start at index 0 to create the outParams
Map.
                   // If there IS a return, then we start with 1.
                   int outParamStart = 0;
  -                
  +
                   // If we have resArgs and the returnType is specified, then the first
                   // resArgs is the return.  If we have resArgs and neither returnType
                   // nor paramTypes are specified, then we assume that the caller is
  @@ -1612,12 +1622,16 @@
                   // types match the expected returnType and paramTypes, but I'm not
                   // sure how to do that since the resArgs value is a Java Object
                   // and the returnType and paramTypes are QNames.
  -                if (returnType != null || paramTypes == null) {
  +
  +                // GD 03/15/02 : We're now checking for invalid metadata
  +                // config at the top of this method, so don't need to do it
  +                // here.  Check for void return, though.
  +                if (!XMLType.AXIS_VOID.equals(returnType)) {
                       RPCParam param = (RPCParam)resArgs.get(0);
                       result = param.getValue();
                       outParamStart = 1;
                   }
  -                
  +
                   for (int i = outParamStart; i < resArgs.size(); i++) {
                       RPCParam param = (RPCParam) resArgs.get(i);
                       outParams.put(param.getQName(), param.getValue());
  @@ -1656,7 +1670,7 @@
       public void setOption(String name, Object value) {
           service.getEngine().setOption(name, value);
       }
  -    
  +
       /**
        * Invoke this Call with its established MessageContext
        * (perhaps because you called this.setRequestMessage())
  @@ -1717,7 +1731,7 @@
   
           if ( body.getPrefix() == null )       body.setPrefix( "m" );
           if ( body.getNamespaceURI() == null ) {
  -            throw new AxisFault("Call.invoke", 
  +            throw new AxisFault("Call.invoke",
                      JavaUtils.getMessage("cantInvoke00", body.getName()),
                                           null, null);
           } else if (msgContext.getService() == null) {
  @@ -1752,22 +1766,22 @@
           }
   
           service.getEngine().invoke( msgContext );
  -        
  +
           if (transport != null)
               transport.processReturnedMessageContext(msgContext);
  -        
  +
           Message resMsg = msgContext.getResponseMessage();
  -        
  +
           if (resMsg == null)
               throw new AxisFault(JavaUtils.getMessage("nullResponse00"));
  -        
  +
           /** This must happen before deserialization...
            */
           resMsg.setMessageType(Message.RESPONSE);
  -        
  +
           SOAPEnvelope resEnv = (SOAPEnvelope)resMsg.getSOAPPart().
                   getAsSOAPEnvelope();
  -        
  +
           SOAPBodyElement respBody = resEnv.getFirstBody();
           if (respBody instanceof SOAPFaultElement) {
               throw ((SOAPFaultElement)respBody).getFault();
  
  
  

Mime
View raw message