axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/encoding XMLType.java
Date Thu, 04 Oct 2001 17:25:09 GMT
dug         01/10/04 10:25:09

  Modified:    java/samples/stock GetQuote.wsdl GetQuote1.java
               java/src/org/apache/axis/client Call.java Service.java
               java/src/org/apache/axis/encoding XMLType.java
  Log:
  Set the param names/types, and the result type from the WSDL.
  
  Revision  Changes    Path
  1.2       +1 -1      xml-axis/java/samples/stock/GetQuote.wsdl
  
  Index: GetQuote.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/stock/GetQuote.wsdl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetQuote.wsdl	2001/10/03 15:44:57	1.1
  +++ GetQuote.wsdl	2001/10/04 17:25:09	1.2
  @@ -18,7 +18,7 @@
   
     <!-- port type declns -->
     <portType name="GetQuote">
  -    <operation name="getQuote">
  +    <operation name="getQuote" >
         <input  message="tns:GetQuoteRequest"/>
         <output message="tns:GetQuoteResponse"/>
       </operation>
  
  
  
  1.5       +4 -2      xml-axis/java/samples/stock/GetQuote1.java
  
  Index: GetQuote1.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/stock/GetQuote1.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- GetQuote1.java	2001/10/04 13:45:06	1.4
  +++ GetQuote1.java	2001/10/04 17:25:09	1.5
  @@ -87,14 +87,16 @@
         }
   
         // Define the service QName and port QName
  +      /////////////////////////////////////////////////////////////////////////
         QName servQN = new QName("urn:xmltoday-delayed-quotes","GetQuoteService");
         QName portQN = new QName("urn:xmltoday-delayed-quotes","GetQuote");
   
         Service service = new Service( "GetQuote.wsdl", servQN );
         Call    call    = service.createCall( portQN, "getQuote" );
   
  -      //  set params, return-type   - dug
  -
  +      // Define some service and Axis specific properties
  +      // Namespace should be part of JAXRPC but it isn't - too bad
  +      ////////////////////////////////////////////////////////////////////////
         call.setProperty( Constants.NAMESPACE, "urn:xmltoday-delayed-quotes" );
         call.setProperty( Transport.USER, opts.getUser() );
         call.setProperty( Transport.PASSWORD, opts.getPassword() );
  
  
  
  1.4       +78 -12    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Call.java	2001/10/04 13:38:07	1.3
  +++ Call.java	2001/10/04 17:25:09	1.4
  @@ -58,9 +58,12 @@
   import org.apache.axis.AxisFault;
   import org.apache.axis.Constants;
   import org.apache.axis.encoding.ServiceDescription;
  +import org.apache.axis.message.RPCParam;
   import org.apache.axis.rpc.encoding.XMLType;
   import org.apache.axis.rpc.namespace.QName;
   
  +import java.util.Vector ;
  +
   /**
    * Axis' JAXRPC Dynamic Invocation Interface implementation of the Call
    * interface.  This class should be used to actually invoke the Web Service.
  @@ -75,6 +78,9 @@
       private ServiceClient      client        = null ;
       private ServiceDescription serviceDesc   = null ;
       private String             operationName = null ;
  +    private Vector             paramNames    = null ;
  +    private Vector             paramTypes    = null ;
  +    private Vector             paramModes    = null ;
   
       /**
        * Default constructor - not much else to say.
  @@ -117,14 +123,25 @@
   
           QName qn = paramType.getType();
   
  +        if ( paramNames == null ) {
  +            paramNames = new Vector();
  +            paramTypes = new Vector();
  +            paramModes = new Vector();
  +        }
  +        
  +        paramNames.add( paramName );
  +        paramTypes.add( paramType.getType() );
  +        paramModes.add( new Integer(parameterMode) );
  +
  +/*
           switch( parameterMode ) {
  -            case PARAM_MODE_IN: 
  -                     serviceDesc.addInputParam( paramName,
  -                         new org.apache.axis.utils.QName(qn.getNamespaceURI(),
  -                                                         qn.getLocalPart() ) );
  +            case PARAM_MODE_IN: paramNames.add( paramName );
  +                                paramTypes.add( qn );
  +                                paramModes.add( PARAM_MODE_IN );
                        break ;
   
  -            case PARAM_MODE_OUT:
  +            case PARAM_MODE_OUT: paramNames.add( paramName );
  +                    
                        serviceDesc.addOutputParam( paramName,
                            new org.apache.axis.utils.QName(qn.getNamespaceURI(),
                                                            qn.getLocalPart() ) );
  @@ -134,6 +151,7 @@
               default:                // Unsupported - but can't throw anything!
                         throw new RuntimeException( "Unsupport parameter type" );
           }
  +        */
       }
   
       /**
  @@ -264,18 +282,17 @@
        * @return Object Return value of the operation/method - or null
        * @throws RemoteException if there's an error
        */
  -    public Object invoke(Object[] params)
  -                           throws java.rmi.RemoteException {
  +    public Object invoke(Object[] params) throws java.rmi.RemoteException {
           if ( operationName == null )
               throw new java.rmi.RemoteException( "No operation name specified" );
           try {
               String ns = (String) client.get( Constants.NAMESPACE );
               if ( ns == null )
  -                return( client.invoke( operationName, params ) );
  +                return( client.invoke(operationName,getParamList(params)) );
               else
  -                return( client.invoke( ns, operationName, params ) );
  +                return( client.invoke(ns,operationName,getParamList(params)) );
           }
  -        catch( AxisFault exp ) {
  +        catch( Exception exp ) {
               throw new java.rmi.RemoteException( "Error invoking operation",
                                                   exp );
           }
  @@ -295,10 +312,59 @@
       public void invokeOneWay(Object[] params)
                              throws org.apache.axis.rpc.JAXRPCException {
           try {
  -            invoke( params );
  +            invoke( getParamList(params) );
           }
  -        catch( java.rmi.RemoteException exp ) {
  +        catch( Exception exp ) {
               throw new org.apache.axis.rpc.JAXRPCException( exp.toString() );
           }
  +    }
  +
  +    /**
  +     * Convert the list of objects into RPCParam's based on the paramNames,
  +     * paramTypes and paramModes variables.  If those aren't set then just
  +     * return what was passed in.
  +     *
  +     * @param  params   Array of parameters to pass into the operation/method
  +     * @return Object[] Array of parameters to pass to invoke()
  +     */
  +    private Object[] getParamList(Object[] params) 
  +                           throws org.apache.axis.rpc.JAXRPCException {
  +        int  numParams = 0 ;
  +        int  i ;
  +
  +        // If we never set-up any names... then just return what was passed in
  +        //////////////////////////////////////////////////////////////////////
  +        if ( paramNames == null ) return( params );
  +
  +        // Count the number of IN and INOUT params, this needs to match the
  +        // number of params passed in - if not throw an error
  +        /////////////////////////////////////////////////////////////////////
  +        for ( i = 0 ; i < paramNames.size() ; i++ ) {
  +            if (((Integer)paramModes.get(i)).intValue() == Call.PARAM_MODE_OUT)
  +                continue ;
  +            numParams++ ;
  +        }
  +
  +        if ( numParams != params.length )
  +            throw new org.apache.axis.rpc.JAXRPCException( 
  +                                       "Number of parameters passed in (" +
  +                                       params.length + ") doesn't match the " +
  +                                       "number of IN/INOUT parameters (" + 
  +                                       numParams + ") from the addParameter" +
  +                                       "() calls" );
  +
  +        // All ok - so now produce an array of RPCParams
  +        //////////////////////////////////////////////////
  +        Vector result = new Vector();
  +        int    j = 0 ;
  +        for ( i = 0 ; i < numParams ; i++ ) {
  +            if (((Integer)paramModes.get(i)).intValue() == Call.PARAM_MODE_OUT)
  +                continue ;
  +            RPCParam p = new RPCParam( (String) paramNames.get(i), 
  +                                          params[j++] );
  +            result.add( p );
  +        }
  +
  +        return( result.toArray() );
       }
   }
  
  
  
  1.8       +79 -27    xml-axis/java/src/org/apache/axis/client/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Service.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Service.java	2001/10/04 16:49:08	1.7
  +++ Service.java	2001/10/04 17:25:09	1.8
  @@ -55,30 +55,38 @@
   
   package org.apache.axis.client ;
   
  -import com.ibm.wsdl.extensions.soap.SOAPAddress;
  -import com.ibm.wsdl.extensions.soap.SOAPOperation;
  -import com.ibm.wsdl.xml.WSDLReader;
  -import org.apache.axis.rpc.JAXRPCException;
  -import org.apache.axis.rpc.namespace.QName;
  -import org.apache.axis.transport.http.HTTPConstants;
  -import org.apache.axis.utils.XMLUtils;
  -
  -import javax.wsdl.Binding;
  -import javax.wsdl.BindingOperation;
  -import javax.wsdl.Definition;
  -import javax.wsdl.Message;
  -import javax.wsdl.Operation;
  -import javax.wsdl.Output;
  -import javax.wsdl.Port;
  -import javax.wsdl.PortType;
  -import java.io.FileInputStream;
  -import java.io.InputStream;
  -import java.net.URL;
  -import java.util.HashSet;
  -import java.util.Iterator;
  -import java.util.List;
  -import java.util.Map;
  -import java.util.Set;
  +import java.net.URL ;
  +import java.lang.String ;
  +import java.util.Map ;
  +import java.util.Set ;
  +import java.util.List ;
  +import java.util.Iterator ;
  +import java.util.HashSet ;
  +
  +import java.io.InputStream ;
  +import java.io.FileInputStream ;
  +
  +import org.apache.axis.utils.XMLUtils ;
  +
  +import org.apache.axis.encoding.XMLType ;
  +import org.apache.axis.rpc.JAXRPCException ;
  +import org.apache.axis.rpc.namespace.QName ;
  +import org.apache.axis.transport.http.HTTPConstants ;
  +
  +import javax.wsdl.Definition ;
  +import javax.wsdl.Binding ;
  +import javax.wsdl.BindingOperation ;
  +import javax.wsdl.Input ;
  +import javax.wsdl.Message ;
  +import javax.wsdl.Operation ;
  +import javax.wsdl.Output ;
  +import javax.wsdl.Part ;
  +import javax.wsdl.Port ;
  +import javax.wsdl.PortType ;
  +
  +import com.ibm.wsdl.xml.WSDLReader ;
  +import com.ibm.wsdl.extensions.soap.SOAPAddress ;
  +import com.ibm.wsdl.extensions.soap.SOAPOperation ;
   
   /**
    * Axis' JAXRPC Dynamic Invoation Interface implementation of the Service
  @@ -355,12 +363,56 @@
   
           // Get the parameters
           ////////////////////////////////////////////////////////////////////
  -        // to do - dug
  +        List    paramOrder = op.getParameterOrdering();
  +        Input   input      = op.getInput();
  +        Message message    = null ;
  +        List    parts      = null ;
  +
  +        if ( input   != null ) message = input.getMessage();
  +        if ( message != null ) parts   = message.getOrderedParts( paramOrder );
  +        if ( parts != null ) {
  +            for ( int i = 0 ; i < parts.size() ; i++ ) {
  +                Part    part = (Part) parts.get(i);
  +                // Part    part = message.getPart( name );
  +                if ( part == null ) continue ;
  +
  +                String           name  = part.getName();
  +                javax.wsdl.QName type  = part.getTypeName();
  +                QName            tmpQN = new QName( type.getNamespaceURI(),
  +                                                    type.getLocalPart());
  +                XMLType          xmlType = new XMLType(tmpQN);
  +                int              mode = Call.PARAM_MODE_IN ;
  +                call.addParameter( name, xmlType, mode );
   
  +                // System.err.println("Adding param: " + name );
  +            }
  +        }
  +
  +
           // Get the return type
           ////////////////////////////////////////////////////////////////////
  -        Output   output = op.getOutput();
  -        Message  messae = output.getMessage();
  +        Output   output  = op.getOutput();
  +        message = null ;
  +
  +        if ( output  != null ) message = output.getMessage();
  +        if ( message != null ) parts   = message.getOrderedParts(null);
  +
  +        if ( parts != null ) {
  +            for( int i = 0 ;i < parts.size() ; i++ ) {
  +                Part part  = (Part) parts.get( i );
  +
  +                if (paramOrder != null && paramOrder.contains(part.getName()))
  +                        continue ;
  +
  +                javax.wsdl.QName type  = part.getTypeName();
  +                QName            tmpQN = new QName( type.getNamespaceURI(),
  +                                                    type.getLocalPart());
  +                XMLType          xmlType = new XMLType(tmpQN);
  +                call.setReturnType( xmlType );
  +                // System.err.println("Return type: " + type.getLocalPart() );
  +                break ;
  +            }
  +        }
   
           return( call );
       }
  
  
  
  1.3       +0 -5      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLType.java	2001/10/03 15:30:04	1.2
  +++ XMLType.java	2001/10/04 17:25:09	1.3
  @@ -120,8 +120,3 @@
           this.type = type ;
       }
   }
  -
  -
  -
  -
  -    
  
  
  

Mime
View raw message