butek       02/02/08 12:48:21

  Modified:    java/src/org/apache/axis MessageContext.java
               java/src/org/apache/axis/client Call.java Stub.java
               java/src/org/apache/axis/transport/http HTTPConstants.java
               java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java
  Log:
  Improve performance of Call/MessageContext properties in 3 steps:
  
  1.  (the work in this commit) Turn the common properties into accessors while still
  making them available via get/setProperty.
  
  2.  (near future commit) Call the accessors in the runtime rather than 
get/setProperty.
  Remove all the various constant property name declarations and stick with one set
  (presumably in Call?).
  
  3.  (far future commit)  Implement nested properties so that we don't have properties
  objects in each of Stub/Call/MessageContext/(anything else?).  I don't know if this
  idea can be reconciled with properties-as-accessors, but I'll think about it.
  
  Revision  Changes    Path
  1.72      +246 -11   xml-axis/java/src/org/apache/axis/MessageContext.java
  
  Index: MessageContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- MessageContext.java       8 Feb 2002 03:09:25 -0000       1.71
  +++ MessageContext.java       8 Feb 2002 20:48:20 -0000       1.72
  @@ -56,9 +56,11 @@
   package org.apache.axis ;
   
   import org.apache.axis.client.AxisClient;
  +import org.apache.axis.client.Call;
   import org.apache.axis.encoding.TypeMappingRegistry;
   import org.apache.axis.handlers.soap.SOAPService;
   import org.apache.axis.session.Session;
  +import org.apache.axis.utils.JavaUtils;
   import org.apache.log4j.Category;
   
   import java.util.Hashtable;
  @@ -157,6 +159,17 @@
       private Hashtable bag ;
       
       /**
  +     * These variables are logically part of the bag, but are separated
  +     * because they are used often and the Hashtable is more expensive.
  +     */
  +    private String  username       = null;
  +    private String  password       = null;
  +    private String  operationStyle = null;
  +    private boolean useSOAPAction  = false;
  +    private String  SOAPActionURI  = null;
  +    private String  encodingStyle  = Constants.URI_CURRENT_SOAP_ENC;
  +
  +    /**
        * Are we using SOAP encoding?  Default is true for RPC services,
        * should be set to false for document/literal.
        */ 
  @@ -466,11 +479,11 @@
       
       /** A String with the user's ID (if available)
        */
  -    public static String USERID              = "user.id";
  +    public static String USERID              = Call.USERNAME_PROPERTY;
   
       /** A String with the user's password (if available)
        */
  -    public static String PASSWORD            = "user.password";
  +    public static String PASSWORD            = Call.PASSWORD_PROPERTY;
   
       /** Place to store an AuthenticatedUser */
       public static String AUTHUSER            = "authenticatedUser";
  @@ -550,17 +563,239 @@
           return( true );
       }
   
  -    public Object getProperty(String propName) {
  -        if ( bag == null ) return( null );
  -        return( bag.get(propName) );
  -    }
  +    /**
  +     * Allows you to set a named property to the passed in value.
  +     * There are a few known properties (like username, password, etc)
  +     * that are variables in Call.  The rest of the properties are
  +     * stored in a Hashtable.  These common properties should be
  +     * accessed via the accessors for speed/type safety, but they may
  +     * still be obtained via this method.  It's up to one of the
  +     * Handlers (or the Axis engine itself) to go looking for
  +     * one of them.
  +     *
  +     * @param name  Name of the property
  +     * @param value Value of the property
  +     */
  +    public void setProperty(String name, Object value) {
  +        if (name == null || value == null) {
  +            return;
  +            // Is this right?  Shouldn't we throw an exception like: throw new 
IllegalArgumentException();
  +        }
  +        else if (name.equals(Call.USERNAME_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[] {
  +                        name, "java.lang.String", value.getClass().getName()}));
  +            }
  +            setUsername((String) value);
  +        }
  +        else if (name.equals(Call.PASSWORD_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[] {
  +                        name, "java.lang.String", value.getClass().getName()}));
  +            }
  +            setPassword((String) value);
  +        }
  +        else if (name.equals(Call.SESSION_PROPERTY)) {
  +            if (!(value instanceof Boolean)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[]
  +                        {name,
  +                        "java.lang.Boolean",
  +                        value.getClass().getName()}));
  +            }
  +            setMaintainSession(((Boolean) value).booleanValue());
  +        }
  +        else if (name.equals(Call.OPERATION_STYLE_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[] {
  +                        name, "java.lang.String", value.getClass().getName()}));
  +            }
  +            setOperationStyle((String) value);
  +        }
  +        else if (name.equals(Call.SOAPACTION_USE_PROPERTY)) {
  +            if (!(value instanceof Boolean)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[]
  +                        {name,
  +                        "java.lang.Boolean",
  +                        value.getClass().getName()}));
  +            }
  +            setUseSOAPAction(((Boolean) value).booleanValue());
  +        }
  +        else if (name.equals(Call.SOAPACTION_URI_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[]
  +                        {name,
  +                        "java.lang.String",
  +                        value.getClass().getName()}));
  +            }
  +            setSOAPActionURI((String) value);
  +        }
  +        else if (name.equals(Call.ENCODING_STYLE_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[]
  +                        {name,
  +                        "java.lang.String",
  +                        value.getClass().getName()}));
  +            }
  +            setEncodingStyle((String) value);
  +        }
  +        else {
  +            if (bag == null) {
  +                bag = new Hashtable();
  +            }
  +            bag.put(name, value);
  +        }
  +    } // setProperty
   
  -    public void setProperty(String propName, Object propValue) {
  -        if (propValue == null) return;
  -        if ( bag == null ) bag = new Hashtable() ;
  -        bag.put( propName, propValue );
  +    /**
  +     * Returns the value associated with the named property - or null if not
  +     * defined/set.
  +     *
  +     * @return Object value of the property - or null
  +     */
  +    public Object getProperty(String name) {
  +        if (name != null) {
  +            if (name.equals(Call.USERNAME_PROPERTY)) {
  +                return getUsername();
  +            }
  +            else if (name.equals(Call.PASSWORD_PROPERTY)) {
  +                return getPassword();
  +            }
  +            else if (name.equals(Call.SESSION_PROPERTY)) {
  +                return new Boolean(getMaintainSession());
  +            }
  +            else if (name.equals(Call.OPERATION_STYLE_PROPERTY)) {
  +                return getOperationStyle();
  +            }
  +            else if (name.equals(Call.SOAPACTION_USE_PROPERTY)) {
  +                return new Boolean(useSOAPAction());
  +            }
  +            else if (name.equals(Call.SOAPACTION_URI_PROPERTY)) {
  +                return getSOAPActionURI();
  +            }
  +            else if (name.equals(Call.ENCODING_STYLE_PROPERTY)) {
  +                return getEncodingStyle();
  +            }
  +            else if (bag == null) {
  +                return null;
  +            }
  +            else {
  +                return bag.get(name);
  +            }
  +        }
  +        else {
  +            return null;
  +        }
       }
  -    
  +
  +    /**
  +     * Set the username.
  +     */
  +    public void setUsername(String username) {
  +        this.username = username;
  +    } // setUsername
  +
  +    /**
  +     * Get the user name
  +     */
  +    public String getUsername() {
  +        return username;
  +    } // getUsername
  +
  +    /**
  +     * Set the password.
  +     */
  +    public void setPassword(String password) {
  +        this.password = password;
  +    } // setPassword
  +
  +    /**
  +     * Get the password
  +     */
  +    public String getPassword() {
  +        return password;
  +    } // getPassword
  +
  +    /**
  +     * Set the operation style.  IllegalArgumentException is thrown if 
operationStyle
  +     * is not "rpc" or "document".
  +     *
  +     * @exception IllegalArgumentException if operationStyle is not "rpc" or 
"document".
  +     */
  +    public void setOperationStyle(String operationStyle) {
  +        if ("rpc".equalsIgnoreCase(operationStyle)
  +                || "document".equalsIgnoreCase(operationStyle)) {
  +            this.operationStyle = operationStyle;
  +        }
  +        else {
  +            throw new IllegalArgumentException(JavaUtils.getMessage(
  +                    "badProp01",
  +                    new String[] {Call.OPERATION_STYLE_PROPERTY,
  +                    "\"rpc\", \"document\"", operationStyle}));
  +        }
  +    } // setOperationStyle
  +
  +    /**
  +     * Get the operation style.
  +     */
  +    public String getOperationStyle() {
  +        return operationStyle;
  +    } // getOperationStyle
  +
  +    /**
  +     * Should soapAction be used?
  +     */
  +    public void setUseSOAPAction(boolean useSOAPAction) {
  +        this.useSOAPAction = useSOAPAction;
  +    } // setUseSOAPAction
  +
  +    /**
  +     * Are we using soapAction?
  +     */
  +    public boolean useSOAPAction() {
  +        return useSOAPAction;
  +    } // useSOAPAction
  +
  +    /**
  +     * Set the soapAction URI.
  +     */
  +    public void setSOAPActionURI(String SOAPActionURI)
  +            throws IllegalArgumentException {
  +        this.SOAPActionURI = SOAPActionURI;
  +    } // setSOAPActionURI
  +
  +    /**
  +     * Get the soapAction URI.
  +     */
  +    public String getSOAPActionURI() {
  +        return SOAPActionURI;
  +    } // getSOAPActionURI
  +
  +    /**
  +     * Sets the encoding style to the URL passed in.
  +     *
  +     * @param namespaceURI URI of the encoding to use.
  +     */
  +    public void setEncodingStyle(String namespaceURI) {
  +        encodingStyle = namespaceURI;
  +    } // setEncodingStype
  +
  +    /**
  +     * Returns the encoding style as a URI that should be used for the SOAP
  +     * message.
  +     *
  +     * @return String URI of the encoding style to use
  +     */
  +    public String getEncodingStyle() {
  +        return encodingStyle;
  +    } // getEncodingStyle
  +
       public void clearProperty(String propName)
       {
           if (bag != null) {
  
  
  
  1.69      +365 -238  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.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- Call.java 6 Feb 2002 15:17:17 -0000       1.68
  +++ Call.java 8 Feb 2002 20:48:20 -0000       1.69
  @@ -143,16 +143,21 @@
       private Vector             paramNames      = null ;
       private Vector             paramTypes      = null ;
       private Vector             paramModes      = null ;
  -    private String             encodingStyle   = Constants.URI_CURRENT_SOAP_ENC ;
       private QName              returnType      = null ;
   
       private MessageContext     msgContext      = null ;
   
       // Collection of properties to store and put in MessageContext at
  -    // invoke() time
  -    private Hashtable          myProperties    = null ;
  -
  +    // invoke() time.  Known ones are stored in actual variables for
  +    // efficiency/type-consistency.  Unknown ones are in myProperties.
  +    private Hashtable          myProperties    = new Hashtable();
  +    private String             username        = null;
  +    private String             password        = null;
       private boolean            maintainSession = false;
  +    private String             operationStyle  = null;
  +    private boolean            useSOAPAction   = false;
  +    private String             SOAPActionURI   = null;
  +    private String             encodingStyle   = Constants.URI_CURRENT_SOAP_ENC;
   
   
       // Our Transport, if any
  @@ -183,7 +188,7 @@
               "javax.xml.rpc.soap.http.soapaction.use";
       public static final String SOAPACTION_URI_PROPERTY =
               "javax.xml.rpc.soap.http.soapaction.uri";
  -    public static final String NAMESPACE_URI_PROPERTY =
  +    public static final String ENCODING_STYLE_PROPERTY =
               "javax.xml.rpc.encodingstyle.namespace.uri";
   
       /**
  @@ -233,6 +238,260 @@
           setTargetEndpointAddress(url);
       }
   
  +    ////////////////////////////
  +    //
  +    // Properties and the shortcuts for common ones.
  +    //
  +
  +    /**
  +     * Allows you to set a named property to the passed in value.
  +     * There are a few known properties (like username, password, etc)
  +     * that are variables in Call.  The rest of the properties are
  +     * stored in a Hashtable.  These common properties should be
  +     * accessed via the accessors for speed/type safety, but they may
  +     * still be obtained via this method.  It's up to one of the
  +     * Handlers (or the Axis engine itself) to go looking for
  +     * one of them.
  +     *
  +     * @param name  Name of the property
  +     * @param value Value of the property
  +     */
  +    public void setProperty(String name, Object value) {
  +        if (name == null || value == null) {
  +            return;
  +            // Is this right?  Shouldn't we throw an exception like: throw new 
IllegalArgumentException();
  +        }
  +        else if (name.equals(USERNAME_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[] {
  +                        name, "java.lang.String", value.getClass().getName()}));
  +            }
  +            setUsername((String) value);
  +        }
  +        else if (name.equals(PASSWORD_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[] {
  +                        name, "java.lang.String", value.getClass().getName()}));
  +            }
  +            setPassword((String) value);
  +        }
  +        else if (name.equals(SESSION_PROPERTY)) {
  +            if (!(value instanceof Boolean)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[]
  +                        {name,
  +                        "java.lang.Boolean",
  +                        value.getClass().getName()}));
  +            }
  +            setMaintainSession(((Boolean) value).booleanValue());
  +        }
  +        else if (name.equals(OPERATION_STYLE_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[] {
  +                        name, "java.lang.String", value.getClass().getName()}));
  +            }
  +            setOperationStyle((String) value);
  +        }
  +        else if (name.equals(SOAPACTION_USE_PROPERTY)) {
  +            if (!(value instanceof Boolean)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[]
  +                        {name,
  +                        "java.lang.Boolean",
  +                        value.getClass().getName()}));
  +            }
  +            setUseSOAPAction(((Boolean) value).booleanValue());
  +        }
  +        else if (name.equals(SOAPACTION_URI_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[]
  +                        {name,
  +                        "java.lang.String",
  +                        value.getClass().getName()}));
  +            }
  +            setSOAPActionURI((String) value);
  +        }
  +        else if (name.equals(ENCODING_STYLE_PROPERTY)) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[]
  +                        {name,
  +                        "java.lang.String",
  +                        value.getClass().getName()}));
  +            }
  +            setEncodingStyle((String) value);
  +        }
  +        else if ( name.equals(TRANSPORT_NAME) ) {
  +            if (!(value instanceof String)) {
  +                throw new IllegalArgumentException(
  +                        JavaUtils.getMessage("badProp00", new String[] {
  +                        name, "java.lang.String", value.getClass().getName()}));
  +            }
  +            transportName = (String) value ;
  +            if (transport != null)
  +                transport.setTransportName((String) value);
  +        }
  +        else {
  +            myProperties.put(name, value);
  +        }
  +    } // setProperty
  +
  +    /**
  +     * Returns the value associated with the named property - or null if not
  +     * defined/set.
  +     *
  +     * @return Object value of the property - or null
  +     */
  +    public Object getProperty(String name) {
  +        if (name != null) {
  +            if (name.equals(USERNAME_PROPERTY)) {
  +                return getUsername();
  +            }
  +            else if (name.equals(PASSWORD_PROPERTY)) {
  +                return getPassword();
  +            }
  +            else if (name.equals(SESSION_PROPERTY)) {
  +                return new Boolean(getMaintainSession());
  +            }
  +            else if (name.equals(OPERATION_STYLE_PROPERTY)) {
  +                return getOperationStyle();
  +            }
  +            else if (name.equals(SOAPACTION_USE_PROPERTY)) {
  +                return new Boolean(useSOAPAction());
  +            }
  +            else if (name.equals(SOAPACTION_URI_PROPERTY)) {
  +                return getSOAPActionURI();
  +            }
  +            else if (name.equals(ENCODING_STYLE_PROPERTY)) {
  +                return getEncodingStyle();
  +            }
  +            else if (name.equals(TRANSPORT_NAME)) {
  +                return transportName;
  +            }
  +            else {
  +                return myProperties.get(name);
  +            }
  +        }
  +        else {
  +            return null;
  +        }
  +    }
  +
  +    /**
  +     * Set the username.
  +     */
  +    public void setUsername(String username) {
  +        this.username = username;
  +    } // setUsername
  +
  +    /**
  +     * Get the user name
  +     */
  +    public String getUsername() {
  +        return username;
  +    } // getUsername
  +
  +    /**
  +     * Set the password.
  +     */
  +    public void setPassword(String password) {
  +        this.password = password;
  +    } // setPassword
  +
  +    /**
  +     * Get the password
  +     */
  +    public String getPassword() {
  +        return password;
  +    } // getPassword
  +
  +    /**
  +     * Determine whether we'd like to track sessions or not.  This
  +     * overrides the default setting from the service.
  +     * This just passes through the value into the MessageContext.
  +     * Note: Not part of JAX-RPC specification.
  +     *
  +     * @param yesno true if session state is desired, false if not.
  +     */
  +    public void setMaintainSession(boolean yesno) {
  +        maintainSession = yesno;
  +    }
  +
  +    /**
  +     * Get the value of maintainSession flag.
  +     */
  +    public boolean getMaintainSession() {
  +        return maintainSession;
  +    }
  +
  +    /**
  +     * Set the operation style.  IllegalArgumentException is thrown if 
operationStyle
  +     * is not "rpc" or "document".
  +     *
  +     * @exception IllegalArgumentException if operationStyle is not "rpc" or 
"document".
  +     */
  +    public void setOperationStyle(String operationStyle) {
  +        if ("rpc".equalsIgnoreCase(operationStyle)
  +                || "document".equalsIgnoreCase(operationStyle)) {
  +            this.operationStyle = operationStyle;
  +        }
  +        else {
  +            throw new IllegalArgumentException(JavaUtils.getMessage(
  +                    "badProp01",
  +                    new String[] {OPERATION_STYLE_PROPERTY,
  +                    "\"rpc\", \"document\"", operationStyle}));
  +        }
  +    } // setOperationStyle
  +
  +    /**
  +     * Get the operation style.
  +     */
  +    public String getOperationStyle() {
  +        return operationStyle;
  +    } // getOperationStyle
  +
  +    /**
  +     * Should soapAction be used?
  +     */
  +    public void setUseSOAPAction(boolean useSOAPAction) {
  +        this.useSOAPAction = useSOAPAction;
  +    } // setUseSOAPAction
  +
  +    /**
  +     * Are we using soapAction?
  +     */
  +    public boolean useSOAPAction() {
  +        return useSOAPAction;
  +    } // useSOAPAction
  +
  +    /**
  +     * Set the soapAction URI.
  +     */
  +    public void setSOAPActionURI(String SOAPActionURI)
  +            throws IllegalArgumentException {
  +        this.SOAPActionURI = SOAPActionURI;
  +    } // setSOAPActionURI
  +
  +    /**
  +     * Get the soapAction URI.
  +     */
  +    public String getSOAPActionURI() {
  +        return SOAPActionURI;
  +    } // getSOAPActionURI
  +
  +    /**
  +     * Sets the encoding style to the URL passed in.
  +     *
  +     * @param namespaceURI URI of the encoding to use.
  +     */
  +    public void setEncodingStyle(String namespaceURI) {
  +        encodingStyle = namespaceURI;
  +    }
  +
       /**
        * Returns the encoding style as a URI that should be used for the SOAP
        * message.
  @@ -240,18 +499,98 @@
        * @return String URI of the encoding style to use
        */
       public String getEncodingStyle() {
  -        return( encodingStyle );
  +        return encodingStyle;
  +    }
  +
  +   /**
  +     * Removes (if set) the named property.
  +     *
  +     * @param name name of the property to remove
  +     */
  +    public void removeProperty(String name) {
  +        if ( name == null || myProperties == null ) return ;
  +        myProperties.remove( name );
       }
   
       /**
  -     * Sets the encoding style to the URL passed in.
  +     * Sets the URL of the target Web Service.
        *
  -     * @param namespaceURI URI of the encoding to use.
  +     * @param address URL of the target Web Service
        */
  -    public void setEncodingStyle(String namespaceURI) {
  -        encodingStyle = namespaceURI ;
  +    public void setTargetEndpointAddress(java.net.URL address) {
  +        try {
  +            if ( address == null ) {
  +                setTransport(null);
  +                return ;
  +            }
  +
  +            String protocol = address.getProtocol();
  +
  +            // Handle the case where the protocol is the same but we
  +            // just want to change the URL - if so just set the URL,
  +            // creating a new Transport object will drop all session
  +            // data - and we want that stuff to persist between invoke()s.
  +            // Technically the session data should be in the message
  +            // context so that it can be persistent across transports
  +            // as well, but for now the data is in the Transport object.
  +            ////////////////////////////////////////////////////////////////
  +            if ( this.transport != null ) {
  +                String oldAddr = this.transport.getUrl();
  +                if ( oldAddr != null && !oldAddr.equals("") ) {
  +                    URL     tmpURL   = new URL( oldAddr );
  +                    String  oldProto = tmpURL.getProtocol();
  +                    if ( protocol.equals(oldProto) ) {
  +                        this.transport.setUrl( address.toString() );
  +                        return ;
  +                    }
  +                }
  +            }
  +
  +            // Do we already have a transport for this address?
  +            Transport transport = (Transport) transportImpls.get(address);
  +            if (transport != null) {
  +                setTransport(transport);
  +            }
  +            else {
  +            // We don't already have a transport for this address.  Create one.
  +                transport = getTransportForProtocol(protocol);
  +                if (transport == null)
  +                    throw new AxisFault("Call.setTargetEndpointAddress",
  +                                 JavaUtils.getMessage("noTransport01",
  +                                 protocol), null, null);
  +                transport.setUrl(address.toString());
  +                setTransport(transport);
  +                transportImpls.put(address, transport);
  +            }
  +        }
  +        catch( Exception exp ) {
  +            exp.printStackTrace();
  +            // do what?
  +            // throw new AxisFault("Call.setTargetEndpointAddress",
  +                    //"Malformed URL Exception: " + e.getMessage(), null, null);
  +        }
  +    }
  +
  +    /**
  +     * Returns the URL of the target Web Service.
  +     *
  +     * @return URL URL of the target Web Service
  +     */
  +    public java.net.URL getTargetEndpointAddress() {
  +        try {
  +            if ( transport == null ) return( null );
  +            return( new java.net.URL( transport.getUrl() ) );
  +        }
  +        catch( Exception exp ) {
  +            return( null );
  +        }
       }
   
  +    //
  +    // end properties code.
  +    //
  +    ////////////////////////////
  +
       /**
        * Is the caller required to provide the parameter and return type 
specification?  If true, then
        * addParameter and setReturnType MUST be called to provide the meta data.  If 
false, then
  @@ -568,202 +907,6 @@
       }
   
       /**
  -     * Sets the URL of the target Web Service.
  -     *
  -     * @param address URL of the target Web Service
  -     */
  -    public void setTargetEndpointAddress(java.net.URL address) {
  -        try {
  -            if ( address == null ) {
  -                setTransport(null);
  -                return ;
  -            }
  -
  -            String protocol = address.getProtocol();
  -
  -            // Handle the case where the protocol is the same but we
  -            // just want to change the URL - if so just set the URL,
  -            // creating a new Transport object will drop all session
  -            // data - and we want that stuff to persist between invoke()s.
  -            // Technically the session data should be in the message
  -            // context so that it can be persistent across transports
  -            // as well, but for now the data is in the Transport object.
  -            ////////////////////////////////////////////////////////////////
  -            if ( this.transport != null ) {
  -                String oldAddr = this.transport.getUrl();
  -                if ( oldAddr != null && !oldAddr.equals("") ) {
  -                    URL     tmpURL   = new URL( oldAddr );
  -                    String  oldProto = tmpURL.getProtocol();
  -                    if ( protocol.equals(oldProto) ) {
  -                        this.transport.setUrl( address.toString() );
  -                        return ;
  -                    }
  -                }
  -            }
  -
  -            // Do we already have a transport for this address?
  -            Transport transport = (Transport) transportImpls.get(address);
  -            if (transport != null) {
  -                setTransport(transport);
  -            }
  -            else {
  -            // We don't already have a transport for this address.  Create one.
  -                transport = getTransportForProtocol(protocol);
  -                if (transport == null)
  -                    throw new AxisFault("Call.setTargetEndpointAddress",
  -                                 JavaUtils.getMessage("noTransport01",
  -                                 protocol), null, null);
  -                transport.setUrl(address.toString());
  -                setTransport(transport);
  -                transportImpls.put(address, transport);
  -            }
  -        }
  -        catch( Exception exp ) {
  -            exp.printStackTrace();
  -            // do what?
  -            // throw new AxisFault("Call.setTargetEndpointAddress",
  -                    //"Malformed URL Exception: " + e.getMessage(), null, null);
  -        }
  -    }
  -
  -    /**
  -     * Returns the URL of the target Web Service.
  -     *
  -     * @return URL URL of the target Web Service
  -     */
  -    public java.net.URL getTargetEndpointAddress() {
  -        try {
  -            if ( transport == null ) return( null );
  -            return( new java.net.URL( transport.getUrl() ) );
  -        }
  -        catch( Exception exp ) {
  -            return( null );
  -        }
  -    }
  -
  -    /**
  -     * Allows you to set a named property to the passed in value.
  -     * This will just be stored in a Hashtable - it's then up to
  -     * one of the Handler (or the Axis engine itself) to go looking for
  -     * one of them.
  -     *
  -     * @param name  Name of the property
  -     * @param value Value of the property
  -     */
  -    public void setProperty(String name, Object value) {
  -        if (name == null || value == null) {
  -            return;
  -            // Is this right?  Shouldn't we throw an exception like: throw new 
IllegalArgumentException();
  -        }
  -        else if (name.equals(USERNAME_PROPERTY)) {
  -            if (!(value instanceof String)) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp00", new String[] {
  -                        name, "java.lang.String", value.getClass().getName()}));
  -            }
  -        }
  -        else if (name.equals(PASSWORD_PROPERTY)) {
  -            if (!(value instanceof String)) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp00", new String[] {
  -                        name, "java.lang.String", value.getClass().getName()}));
  -            }
  -        }
  -        else if (name.equals(SESSION_PROPERTY)) {
  -            if (!(value instanceof Boolean)) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp00", new String[]
  -                        {name,
  -                        "java.lang.Boolean",
  -                        value.getClass().getName()}));
  -            }
  -        }
  -        else if (name.equals(OPERATION_STYLE_PROPERTY)) {
  -            if (!(value instanceof String)) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp00", new String[] {
  -                        name, "java.lang.String", value.getClass().getName()}));
  -            }
  -            String style = (String) value;
  -            if (!style.equals("rpc") && !style.equals("document")) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp01", new String[] {
  -                        name, "\"rpc\", \"document\"", style}));
  -            }
  -        }
  -        else if (name.equals(SOAPACTION_USE_PROPERTY)) {
  -            if (!(value instanceof Boolean)) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp00", new String[]
  -                        {name,
  -                        "java.lang.Boolean",
  -                        value.getClass().getName()}));
  -            }
  -        }
  -        else if (name.equals(SOAPACTION_URI_PROPERTY)) {
  -            if (!(value instanceof String)) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp00", new String[]
  -                        {name,
  -                        "java.lang.String",
  -                        value.getClass().getName()}));
  -            }
  -            Boolean useSOAP =
  -                    (Boolean) myProperties.get(SOAPACTION_USE_PROPERTY);
  -            if (useSOAP == null || !useSOAP.booleanValue()) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp02", new String[]
  -                        {name, SOAPACTION_USE_PROPERTY, "true"}));
  -            }
  -        }
  -        else if (name.equals(NAMESPACE_URI_PROPERTY)) {
  -            if (!(value instanceof String)) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp00", new String[]
  -                        {name,
  -                        "java.lang.String",
  -                        value.getClass().getName()}));
  -            }
  -        }
  -        else if ( name.equals(TRANSPORT_NAME) ) {
  -            if (!(value instanceof String)) {
  -                throw new IllegalArgumentException(
  -                        JavaUtils.getMessage("badProp00", new String[] {
  -                        name, "java.lang.String", value.getClass().getName()}));
  -            }
  -            transportName = (String) value ;
  -            if (transport != null)
  -                transport.setTransportName((String) value);
  -            return;
  -        }
  -
  -        if (myProperties == null)
  -            myProperties = new Hashtable();
  -        myProperties.put(name, value);
  -    }
  -
  -    /**
  -     * Returns the value associated with the named property - or null if not
  -     * defined/set.
  -     *
  -     * @return Object value of the property - or null
  -     */
  -    public Object getProperty(String name) {
  -        return (name == null || myProperties == null) ? null :
  -                                                        myProperties.get(name);
  -    }
  -
  -    /**
  -     * Removes (if set) the named property.
  -     *
  -     * @param name name of the property to remove
  -     */
  -    public void removeProperty(String name) {
  -        if ( name == null || myProperties == null ) return ;
  -        myProperties.remove( name );
  -    }
  -
  -    /**
        * 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 
  @@ -1107,21 +1250,6 @@
       }
   
       /**
  -     * Determine whether we'd like to track sessions or not.  This
  -     *
  -     * overrides the default setting from the service.
  -     *
  -     * This just passes through the value into the MessageContext.
  -     *
  -     * Note: Not part of JAX-RPC specification.
  -     *
  -     * @param yesno true if session state is desired, false if not.
  -     */
  -    public void setMaintainSession (boolean yesno) {
  -        maintainSession = yesno;
  -    }
  -
  -    /**
        * Obtain a reference to our MessageContext.
        *
        * Note: Not part of JAX-RPC specification.
  @@ -1422,15 +1550,29 @@
           msgContext.reset();
           msgContext.setResponseMessage(null);
           msgContext.setProperty( MessageContext.CALL, this );
  +        if (username != null) {
  +            msgContext.setUsername(username);
  +        }
  +        if (password != null) {
  +            msgContext.setPassword(password);
  +        }
           msgContext.setMaintainSession(maintainSession);
  +        if (operationStyle != null) {
  +            msgContext.setOperationStyle(operationStyle);
  +        }
  +        if (useSOAPAction) {
  +            msgContext.setUseSOAPAction(true);
  +        }
  +        if (SOAPActionURI != null) {
  +            msgContext.setSOAPActionURI(SOAPActionURI);
  +        }
  +        msgContext.setEncodingStyle(encodingStyle);
   
           /**
            * Go thru the properties and ones that are Axis specific, and
            * need to be moved to the msgContext - do so.
            * TBD:
            *   security.auth.subject
  -         *   soap.operation.style
  -         *   encodingstyle.namespace.uri
            */
           if (myProperties != null) {
               Enumeration enum = myProperties.keys();
  @@ -1446,21 +1588,6 @@
                           intValue = Integer.parseInt((String)value);
   
                       msgContext.setTimeout( intValue );
  -                }
  -                else if (name.equals("http.auth.user")) {
  -                    msgContext.setProperty(MessageContext.USERID, value);
  -                }
  -                else if (name.equals("http.auth.password")) {
  -                    msgContext.setProperty(MessageContext.PASSWORD, value);
  -                }
  -                else if (name.equals("soap.http.soapaction.uri")) {
  -                    Object b = getProperty("soap.http.soapaction.use");
  -                    boolean use = false;  
  -                    if (b != null && b instanceof Boolean) {
  -                        use = ((Boolean)b).booleanValue();
  -                    }
  -                    if (use == true) 
  -                        msgContext.setProperty(HTTPConstants.MC_HTTP_SOAPACTION, 
value);
                   }
                   else // Just pass the property through to the message context
                       msgContext.setProperty(name, value);
  
  
  
  1.3       +59 -6     xml-axis/java/src/org/apache/axis/client/Stub.java
  
  Index: Stub.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Stub.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Stub.java 6 Feb 2002 15:17:17 -0000       1.2
  +++ Stub.java 8 Feb 2002 20:48:21 -0000       1.3
  @@ -88,11 +88,13 @@
       // If maintainSession HAS NOT been set, then the
       // Call object uses the default maintainSession
       // from the Service.
  -    protected boolean maintainSessionSet = false;
  -    protected boolean maintainSession = false;
  +    protected boolean    maintainSessionSet = false;
  +    protected boolean    maintainSession    = false;
   
  -    protected URL cachedEndpoint = null;
  -    protected Properties cachedProperties = new Properties();
  +    protected Properties cachedProperties   = new Properties();
  +    protected String     cachedUsername     = null;
  +    protected String     cachedPassword     = null;
  +    protected URL        cachedEndpoint     = null;
   
       /**
        * Sets the value for a named property. JAX-RPC 1.0 specification 
  @@ -118,6 +120,7 @@
                           JavaUtils.getMessage("badProp00", new String[] {
                           name, "java.lang.String", value.getClass().getName()}));
               }
  +            cachedUsername = (String) value;
           }
           else if (name.equals(PASSWORD_PROPERTY)) {
               if (!(value instanceof String)) {
  @@ -125,6 +128,7 @@
                           JavaUtils.getMessage("badProp00", new String[] {
                           name, "java.lang.String", value.getClass().getName()}));
               }
  +            cachedPassword = (String) value;
           }
           else if (name.equals(ADDRESS_PROPERTY)) {
               if (!(value instanceof String)) {
  @@ -150,7 +154,9 @@
               maintainSessionSet = true;
               maintainSession = ((Boolean) value).booleanValue();
           }
  -        cachedProperties.put(name, value);
  +        else {
  +            cachedProperties.put(name, value);
  +        }
       } // _setProperty
   
       /**
  @@ -161,7 +167,26 @@
        * @return the value of a named property.
        */
       public Object _getProperty(String name) {
  -        return cachedProperties.get(name);
  +        if (name != null) {
  +            if (name.equals(USERNAME_PROPERTY)) {
  +                return cachedUsername;
  +            }
  +            else if (name.equals(PASSWORD_PROPERTY)) {
  +                return cachedPassword;
  +            }
  +            else if (name.equals(ADDRESS_PROPERTY)) {
  +                return cachedEndpoint;
  +            }
  +            else if (name.equals(SESSION_PROPERTY)) {
  +                return maintainSessionSet ? new Boolean(maintainSession) : null;
  +            }
  +            else {
  +                return cachedProperties.get(name);
  +            }
  +        }
  +        else {
  +            return null;
  +        }
       } // _getProperty
   
       /**
  @@ -170,6 +195,34 @@
       public Iterator _getPropertyNames() {
           return cachedProperties.keySet().iterator();
       } // _getPropertyNames
  +
  +    /**
  +     * Set the username.
  +     */
  +    public void setUsername(String username) {
  +        cachedUsername = username;
  +    } // setUsername
  +
  +    /**
  +     * Get the user name
  +     */
  +    public String getUsername() {
  +        return cachedUsername;
  +    } // getUsername
  +
  +    /**
  +     * Set the password.
  +     */
  +    public void setPassword(String password) {
  +        cachedPassword = password;
  +    } // setPassword
  +
  +    /**
  +     * Get the password
  +     */
  +    public String getPassword() {
  +        return cachedPassword;
  +    } // getPassword
   
       /**
        * If set to true, session is maintained; if false, it is not.
  
  
  
  1.15      +1 -1      
xml-axis/java/src/org/apache/axis/transport/http/HTTPConstants.java
  
  Index: HTTPConstants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTTPConstants.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- HTTPConstants.java        7 Dec 2001 21:19:04 -0000       1.14
  +++ HTTPConstants.java        8 Feb 2002 20:48:21 -0000       1.15
  @@ -99,7 +99,7 @@
        *  This can be moved to MessageContext.TRANS_SOAPACTION if more transports
        *  have it.
        */
  -    public static String MC_HTTP_SOAPACTION     = "transport.http.soapAction";
  +    public static String MC_HTTP_SOAPACTION = 
org.apache.axis.client.Call.SOAPACTION_URI_PROPERTY;
   
       /** HttpServlet
        */
  
  
  
  1.27      +13 -7     
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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- JavaStubWriter.java       5 Feb 2002 19:37:48 -0000       1.26
  +++ JavaStubWriter.java       8 Feb 2002 20:48:21 -0000       1.27
  @@ -168,16 +168,22 @@
   
           pw.println("    }");
           pw.println();
  -        pw.println("    private javax.xml.rpc.Call getCall() throws 
java.rmi.RemoteException {");
  +        pw.println("    private org.apache.axis.client.Call getCall() throws 
java.rmi.RemoteException {");
           pw.println("        try {");
           pw.println("            org.apache.axis.client.Call call =");
           pw.println("                    (org.apache.axis.client.Call) 
super.service.createCall();");
  -        pw.println("            if (maintainSessionSet) {");
  -        pw.println("                call.setMaintainSession(maintainSession);");
  +        pw.println("            if (super.maintainSessionSet) {");
  +        pw.println("                
call.setMaintainSession(super.maintainSession);");
  +        pw.println("            }");
  +        pw.println("            if (super.cachedUsername != null) {");
  +        pw.println("                call.setUsername(super.cachedUsername);");
  +
  +        pw.println("            }");
  +        pw.println("            if (super.cachedPassword != null) {");
  +        pw.println("                call.setPassword(super.cachedPassword);");
           pw.println("            }");
           pw.println("            if (super.cachedEndpoint != null) {");
           pw.println("                
call.setTargetEndpointAddress(super.cachedEndpoint);");
  -        pw.println("                
call.setProperty(org.apache.axis.transport.http.HTTPTransport.URL, 
super.cachedEndpoint.toString());");
           pw.println("            }");
           pw.println("            java.util.Enumeration keys = 
super.cachedProperties.keys();");
           pw.println("            while (keys.hasMoreElements()) {");
  @@ -434,7 +440,7 @@
           pw.println("        if (super.cachedEndpoint == null) {");
           pw.println("            throw new org.apache.axis.NoEndPointException();");
           pw.println("        }");
  -        pw.println("        javax.xml.rpc.Call call = getCall();");
  +        pw.println("        org.apache.axis.client.Call call = getCall();");
   
           // DUG: need to set the isRPC flag in the Call object
   
  @@ -470,8 +476,8 @@
   
           // SoapAction
           if (soapAction != null) {
  -            pw.println("        call.setProperty(\"soap.http.soapaction.use\", 
Boolean.TRUE);");
  -            pw.println("        call.setProperty(\"soap.http.soapaction.uri\", \"" 
+ soapAction + "\");");
  +            pw.println("        call.setUseSOAPAction(true);");
  +            pw.println("        call.setSOAPActionURI(\"" + soapAction + "\");");
           }
   
           // Encoding literal or encoded use.
  
  
  


Reply via email to