You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2004/11/12 07:38:08 UTC

cvs commit: ws-axis/c/src/transport SOAPTransport.h

samisa      2004/11/11 22:38:08

  Modified:    c/include/axis/client Stub.hpp
               c/src/engine/client Stub.cpp Call.cpp
               c/src/transport/axis2 Axis2Transport.cpp Axis2Transport.h
               c/src/transport SOAPTransport.h
  Log:
  Fixed the problems with setting/getting/deleting trasport propertiess by moving the responsibility of managing them to transport itself. Now the Stub does not cache any of the properties but just passes on the messages to the transport. Fix for Jira AXISCPP-253.
  
  Revision  Changes    Path
  1.7       +13 -8     ws-axis/c/include/axis/client/Stub.hpp
  
  Index: Stub.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/include/axis/client/Stub.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Stub.hpp	9 Nov 2004 02:41:26 -0000	1.6
  +++ Stub.hpp	12 Nov 2004 06:38:07 -0000	1.7
  @@ -150,7 +150,7 @@
       * @return First transport property key. If there are no trasport 
       * properties set, returns NULL.
       */
  -    char* getFirstTrasportPropertyKey();
  +    const char* getFirstTrasportPropertyKey();
   
     /**
       * Iterator for trasport property keys
  @@ -164,7 +164,7 @@
       * @return Next transport property key. If there are no trasport 
       * properties set or if iterator is at the end of the list, returns NULL.
       */
  -    char* getNextTrasportPropertyKey();
  +    const char* getNextTrasportPropertyKey();
   
     /**
       * Accessor for trasport property keys.
  @@ -182,7 +182,7 @@
       * @return Current transport property key. If there are no trasport 
       * properties set or if iterator is at the end of the list, returns NULL.
       */
  -    char* getCurrentTrasportPropertyKey();
  +    const char* getCurrentTrasportPropertyKey();
       
     /**
       * Accessor for trasport property values.
  @@ -202,7 +202,7 @@
       * @return Current transport property value. If there are no trasport 
       * properties set or if iterator is at the end of the list, returns NULL.
       */
  -    char* getCurrentTrasportPropertyValue();
  +    const char* getCurrentTrasportPropertyValue();
   
     /**
       * Deletes the trasport property key:value pair currently pointed to by 
  @@ -561,22 +561,22 @@
     /**
       * Trasport property keys
       */
  -    vector < char *>m_vKeys;
  +//    vector < char *>m_vKeys;
   
     /**
       * Trasport keys iterator
       */
  -    vector <char*>::iterator m_viCurrentKey;
  +//    vector <char*>::iterator m_viCurrentKey;
   
     /**
       * Trasport property values 
       */
  -    vector < char *>m_vValues;
  +//    vector < char *>m_vValues;
     
     /**
       * Trasport keys iterator
       */
  -    vector <char*>::iterator m_viCurrentValue;
  +//    vector <char*>::iterator m_viCurrentValue;
   
     /**
       * Vector of Header Blok pointers
  @@ -612,6 +612,11 @@
       * Session key sent by service 
       */
       std::string m_strSessionKey;
  +    
  +  /**
  +    * Transport object
  +    */
  +    SOAPTransport* m_pTrasport;
   
   };
   
  
  
  
  1.27      +27 -79    ws-axis/c/src/engine/client/Stub.cpp
  
  Index: Stub.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/engine/client/Stub.cpp,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Stub.cpp	9 Nov 2004 02:45:55 -0000	1.26
  +++ Stub.cpp	12 Nov 2004 06:38:08 -0000	1.27
  @@ -32,6 +32,7 @@
       m_pCall = new Call();
       m_pCall->setProtocol(eProtocol);
       m_pCall->setEndpointURI(pcEndPointUri);
  +    m_pTrasport = m_pCall->getTransport();
   
   	// Initialise m_viCurrentSOAPMethodAttribute to something sensible 
   	// in case getFirstSOAPMethodAttribute isn't called first.
  @@ -41,12 +42,12 @@
   Stub::~Stub()
   {
       delete m_pCall;
  -    for (unsigned int i = 0; i < m_vKeys.size(); i++)
  +    /*for (unsigned int i = 0; i < m_vKeys.size(); i++)
       {
   	    delete [] m_vKeys[i];
   	    delete [] m_vValues[i];
       }
  -
  +*/
       for (unsigned int j = 0; j < m_vSOAPHeaderBlocks.size(); j++)
       {
   	    delete m_vSOAPHeaderBlocks[j];
  @@ -60,116 +61,63 @@
   
   void Stub::setTransportProperty(const char *pcKey, const char *pcValue)
   {
  -    if (pcKey && pcValue)
  -    {
  -          char *s = new char[strlen(pcKey)+1];
  -          strcpy(s,pcKey);
  -	    m_vKeys.push_back(s);
  -          s = new char[strlen(pcValue)+1];
  -          strcpy(s,pcValue);
  -	    m_vValues.push_back(s);
  -    }
  +    if (m_pTrasport)
  +        m_pTrasport->setTransportProperty(pcKey, pcValue);
   }
   
   void Stub::setTransportProperties()
   {
  -    SOAPTransport *pTrasport = NULL;
  -    if (m_pCall)
  -	    pTrasport = m_pCall->getTransport();
  -    if (pTrasport)
  +    if (m_pTrasport)
       {
  -	    for (unsigned int i = 0; i < m_vKeys.size(); i++)
  -	    {
  -	        pTrasport->setTransportProperty(m_vKeys[i], m_vValues[i]);
  -	    }
  -        
  -        // set cookie value
  -        // Spec syntax: Cookie: NAME1=OPAQUE_STRING1; NAME2=OPAQUE_STRING2 ...
  -        // This code assumes : Cookie: NAME=VALUE
           if(m_bMaintainSession && (m_strSessionKey.size() > 0) )
           {
  -            pTrasport->setTransportProperty("Cookie", m_strSessionKey.c_str());
  +            m_pTrasport->setTransportProperty("Cookie", m_strSessionKey.c_str());
           }
       }
   }
   
  -char* Stub::getFirstTrasportPropertyKey()
  +const char* Stub::getFirstTrasportPropertyKey()
   {
  -    m_viCurrentKey = m_vKeys.begin();
  -    m_viCurrentValue = m_vValues.begin();
  -
  -    if (m_viCurrentKey == m_vKeys.end())
  -        return NULL;
  +    if (m_pTrasport)
  +        return m_pTrasport->getFirstTrasportPropertyKey();
       else
  -        return (*m_viCurrentKey);
  +        return NULL;
   }
   
  -char* Stub::getNextTrasportPropertyKey()
  +const char* Stub::getNextTrasportPropertyKey()
   {
  -    //already at the end?
  -    if (m_viCurrentKey == m_vKeys.end())
  -        return NULL;
  -
  -    m_viCurrentKey++;
  -    m_viCurrentValue++;
  -
  -    if (m_viCurrentKey == m_vKeys.end())
  -        return NULL;
  +    if (m_pTrasport)
  +        return m_pTrasport->getNextTrasportPropertyKey();
       else
  -        return (*m_viCurrentKey);
  +        return NULL;
   }
   
  -char* Stub::getCurrentTrasportPropertyKey()
  +const char* Stub::getCurrentTrasportPropertyKey()
   {
  -    if (m_viCurrentKey == m_vKeys.end())
  -        return NULL;
  +    if (m_pTrasport)
  +        return m_pTrasport->getCurrentTrasportPropertyKey();
       else
  -        return (*m_viCurrentKey);
  +        return NULL;
   }
   
  -char* Stub::getCurrentTrasportPropertyValue()
  +const char* Stub::getCurrentTrasportPropertyValue()
   {
  -    if (m_viCurrentValue == m_vValues.end())
  -        return NULL;
  +    if (m_pTrasport)
  +        return m_pTrasport->getCurrentTrasportPropertyValue();
       else
  -        return (*m_viCurrentValue);
  +        return NULL;
   }
   
   void Stub::deleteCurrentTrasportProperty()
   {
  -    if (m_viCurrentKey != m_vKeys.end())
  -    {
  -        delete [] *m_viCurrentKey;
  -        delete [] *m_viCurrentValue;
  -        m_vKeys.erase(m_viCurrentKey);
  -        m_vValues.erase(m_viCurrentValue);
  -        m_viCurrentKey = m_vKeys.begin();
  -        m_viCurrentValue = m_vValues.begin();
  -    }
  +    if (m_pTrasport)
  +        m_pTrasport->deleteCurrentTrasportProperty();
   }
   
   void Stub::deleteTrasportProperty(char* pcKey, unsigned int uiOccurance)
   {
  -    vector <char*>::iterator currentKey = m_vKeys.begin();
  -    vector <char*>::iterator currentValue = m_vValues.begin();
  -    unsigned int uiCount = 1;
  -
  -    while(currentKey != m_vKeys.end() && uiCount <= uiOccurance)
  -    {
  -        if(strcmp(pcKey, *currentKey) == 0)
  -        {
  -             if(uiCount == uiOccurance)
  -             {
  -                 delete [] *currentKey;
  -                 delete [] *currentValue;
  -                 m_vKeys.erase(currentKey);
  -                 m_vValues.erase(currentValue);
  -             }
  -             uiCount++;
  -        }
  -        currentKey++;
  -        currentValue++;
  -    }
  +    if (m_pTrasport)
  +        m_pTrasport->deleteTrasportProperty(pcKey, uiOccurance);
   }
   
   void Stub::setHandlerProperty(AxisChar* name, void* value, int len)
  
  
  
  1.74      +2 -0      ws-axis/c/src/engine/client/Call.cpp
  
  Index: Call.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/engine/client/Call.cpp,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- Call.cpp	10 Nov 2004 06:38:33 -0000	1.73
  +++ Call.cpp	12 Nov 2004 06:38:08 -0000	1.74
  @@ -58,6 +58,8 @@
       }
       
       m_pTransport = NULL;
  +    m_nTransportType = APTHTTP1_1;
  +    m_pTransport = SOAPTransportFactory::getTransportObject(m_nTransportType);
       m_nStatus = AXIS_SUCCESS;
   }
   
  
  
  
  1.18      +71 -0     ws-axis/c/src/transport/axis2/Axis2Transport.cpp
  
  Index: Axis2Transport.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/Axis2Transport.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Axis2Transport.cpp	10 Nov 2004 08:30:22 -0000	1.17
  +++ Axis2Transport.cpp	12 Nov 2004 06:38:08 -0000	1.18
  @@ -50,6 +50,7 @@
       m_pcReceived = 0;
       m_pChannel = new Channel ();
       m_bChannelSecure = false;
  +    m_viCurrentHeader = m_vHTTPHeaders.begin();
   }
   
   /*
  @@ -1125,5 +1126,75 @@
       }
   
       return NULL;
  +}
  +
  +const char* Axis2Transport::getFirstTrasportPropertyKey()
  +{
  +    m_viCurrentHeader = m_vHTTPHeaders.begin();
  +    
  +    if (m_viCurrentHeader == m_vHTTPHeaders.end())
  +        return NULL;
  +    else
  +        return (*m_viCurrentHeader).first.c_str();
  +}
  +
  +const char* Axis2Transport::getNextTrasportPropertyKey()
  +{
  +    //already at the end?
  +     if (m_viCurrentHeader == m_vHTTPHeaders.end())
  +        return NULL;
  +    
  +    m_viCurrentHeader++;
  +    
  +    if (m_viCurrentHeader == m_vHTTPHeaders.end())
  +        return NULL;
  +    else
  +        return (*m_viCurrentHeader).first.c_str();
  +        
  +}
  +
  +const char* Axis2Transport::getCurrentTrasportPropertyKey()
  +{
  +    if (m_viCurrentHeader == m_vHTTPHeaders.end())
  +        return NULL;
  +    else
  +        return (*m_viCurrentHeader).first.c_str();
  +}
  +
  +const char* Axis2Transport::getCurrentTrasportPropertyValue()
  +{
  +    if (m_viCurrentHeader == m_vHTTPHeaders.end())
  +        return NULL;
  +    else
  +        return (*m_viCurrentHeader).second.c_str();
  +}
  +
  +void Axis2Transport::deleteCurrentTrasportProperty()
  +{
  +    if (m_viCurrentHeader != m_vHTTPHeaders.end())
  +    {
  +        m_vHTTPHeaders.erase(m_viCurrentHeader);
  +    }
  +}
  +
  +void Axis2Transport::deleteTrasportProperty(char* pcKey, unsigned int uiOccurance)
  +{
  +    vector <std::pair < std::string, std::string > >::iterator currentHeader = m_vHTTPHeaders.begin();
  +    unsigned int uiCount = 1;
  +
  +    while(currentHeader != m_vHTTPHeaders.end() && uiCount <= uiOccurance)
  +    {
  +        if(strcmp(pcKey, (*currentHeader).first.c_str() ) == 0)
  +        {
  +             if(uiCount == uiOccurance)
  +             {                 
  +                 m_vHTTPHeaders.erase(currentHeader);
  +                 break;
  +             }
  +             uiCount++;
  +        }
  +        currentHeader++;
  +    
  +    }
   }
   
  
  
  
  1.12      +97 -1     ws-axis/c/src/transport/axis2/Axis2Transport.h
  
  Index: Axis2Transport.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/Axis2Transport.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Axis2Transport.h	10 Nov 2004 08:30:22 -0000	1.11
  +++ Axis2Transport.h	12 Nov 2004 06:38:08 -0000	1.12
  @@ -120,6 +120,96 @@
   
       // This is used by SimpleAxisServer
       void setSocket (unsigned int);
  +    
  +    /**
  +    * Iterator initiatior for trasport property keys
  +    *
  +    * This method must be called first to initiate access to the list of 
  +    * transport property keys.
  +    *
  +    * @return First transport property key. If there are no trasport 
  +    * properties set, returns NULL.
  +    */
  +    const char* getFirstTrasportPropertyKey();
  +
  +  /**
  +    * Iterator for trasport property keys
  +    *
  +    * getFirstTrasportPropertyKey() method must have been called at least once
  +    * before this method is called. If not behaviour is undefined.
  +    *
  +    * This method advances the iterator by one position.
  +    * Repeated calls always retuen the next value.
  +    *
  +    * @return Next transport property key. If there are no trasport 
  +    * properties set or if iterator is at the end of the list, returns NULL.
  +    */
  +    const char* getNextTrasportPropertyKey();
  +
  +  /**
  +    * Accessor for trasport property keys.
  +    *
  +    * This method gives access to the key corresponding to the trasport key
  +    * currently being pointed by trasport property key iterator.
  +    *
  +    * getFirstTrasportPropertyKey() method must have been called at least once
  +    * before this method is called. If not behaviour is undefined.
  +    *
  +    * This method does not advance the iterator.
  +    * Repeated calls always retuen the same key unless 
  +    * getNextTrasportPropertyKey() is called in between.
  +    *
  +    * @return Current transport property key. If there are no trasport 
  +    * properties set or if iterator is at the end of the list, returns NULL.
  +    */
  +    const char* getCurrentTrasportPropertyKey();
  +    
  +  /**
  +    * Accessor for trasport property values.
  +    *
  +    * This method gives access to the value corresponding to the trasport key
  +    * currently being pointed by trasport property key iterator.
  +    * As keys and values are treated as paires, access to the value field is 
  +    * based on the access to the key field.
  +    *
  +    * getFirstTrasportPropertyKey() method must have been called at least once
  +    * before this method is called. If not behaviour is undefined.
  +    *
  +    * This method does not advance the iterator.
  +    * Repeated calls always retuen the same value unless 
  +    * getNextTrasportPropertyKey() is called in between.
  +    *
  +    * @return Current transport property value. If there are no trasport 
  +    * properties set or if iterator is at the end of the list, returns NULL.
  +    */
  +    const char* getCurrentTrasportPropertyValue();
  +
  +  /**
  +    * Deletes the trasport property key:value pair currently pointed to by 
  +    * the iterator.
  +    */
  +    void deleteCurrentTrasportProperty();
  +
  +  /**
  +    * Deletes the given occerance of the trasport property key:value pair
  +    * corresponding to the given key.
  +    *
  +    * This method does not advance the iterator in line with the deletes done.
  +    * In case you want to access the trasport properties after using this
  +    * method, it is advisable to reinitialize the iterator using
  +    * getFirstTrasportPropertyKey();
  +    * However you can use this method despite where the iterator is 
  +    * pointing currently.
  +    *
  +    * @param pcKey Key of the trasport property key:value pair to be deleted
  +    *              If the given key is not set currently, nothing will happen.
  +    * @param uiOccurance Which occerance of the key to be deleted, because 
  +    *                    there can be multiple values for the same key. 
  +    *                    Default is to delete the first occurance.
  +    *                    Count starts from 1.
  +    */
  +    void deleteTrasportProperty(char* pcKey, unsigned int uiOccurance = 1);
  +
   
     private:
       void processResponseHTTPHeaders ();
  @@ -147,6 +237,12 @@
       * Vector to hold HTTP header key/value pairs
       */
       std::vector < std::pair < std::string, std::string > >m_vHTTPHeaders;
  +    
  +  /**
  +    * Trasport header iterator
  +    */
  +    vector <std::pair < std::string, std::string > >::iterator m_viCurrentHeader;
  +    
     /**
       * HTTP protocol (1.1 or 1.0). Default is HTTP/1.1
       */
  @@ -223,7 +319,7 @@
       Channel *m_pChannel;	// Channel used for communication
       bool m_bChannelSecure;
       std::string m_strHeaderBytesToSend;	// Message header string to be sent.
  -
  +    
   };
   
   #endif
  
  
  
  1.5       +90 -0     ws-axis/c/src/transport/SOAPTransport.h
  
  Index: SOAPTransport.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/SOAPTransport.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SOAPTransport.h	8 Nov 2004 08:49:13 -0000	1.4
  +++ SOAPTransport.h	12 Nov 2004 06:38:08 -0000	1.5
  @@ -343,6 +343,96 @@
       * @param lSeconds Timeout in seconds
       */
       virtual void setTimeout(const long lSeconds) = 0;
  +    
  +    /**
  +    * Iterator initiatior for trasport property keys
  +    *
  +    * This method must be called first to initiate access to the list of 
  +    * transport property keys.
  +    *
  +    * @return First transport property key. If there are no trasport 
  +    * properties set, returns NULL.
  +    */
  +    virtual const char* getFirstTrasportPropertyKey() {};
  +
  +  /**
  +    * Iterator for trasport property keys
  +    *
  +    * getFirstTrasportPropertyKey() method must have been called at least once
  +    * before this method is called. If not behaviour is undefined.
  +    *
  +    * This method advances the iterator by one position.
  +    * Repeated calls always retuen the next value.
  +    *
  +    * @return Next transport property key. If there are no trasport 
  +    * properties set or if iterator is at the end of the list, returns NULL.
  +    */
  +    virtual const char* getNextTrasportPropertyKey() {};
  +
  +  /**
  +    * Accessor for trasport property keys.
  +    *
  +    * This method gives access to the key corresponding to the trasport key
  +    * currently being pointed by trasport property key iterator.
  +    *
  +    * getFirstTrasportPropertyKey() method must have been called at least once
  +    * before this method is called. If not behaviour is undefined.
  +    *
  +    * This method does not advance the iterator.
  +    * Repeated calls always retuen the same key unless 
  +    * getNextTrasportPropertyKey() is called in between.
  +    *
  +    * @return Current transport property key. If there are no trasport 
  +    * properties set or if iterator is at the end of the list, returns NULL.
  +    */
  +    virtual const char* getCurrentTrasportPropertyKey() {};
  +    
  +  /**
  +    * Accessor for trasport property values.
  +    *
  +    * This method gives access to the value corresponding to the trasport key
  +    * currently being pointed by trasport property key iterator.
  +    * As keys and values are treated as paires, access to the value field is 
  +    * based on the access to the key field.
  +    *
  +    * getFirstTrasportPropertyKey() method must have been called at least once
  +    * before this method is called. If not behaviour is undefined.
  +    *
  +    * This method does not advance the iterator.
  +    * Repeated calls always retuen the same value unless 
  +    * getNextTrasportPropertyKey() is called in between.
  +    *
  +    * @return Current transport property value. If there are no trasport 
  +    * properties set or if iterator is at the end of the list, returns NULL.
  +    */
  +    virtual const char* getCurrentTrasportPropertyValue() {};
  +
  +  /**
  +    * Deletes the trasport property key:value pair currently pointed to by 
  +    * the iterator.
  +    */
  +    virtual void deleteCurrentTrasportProperty() {};
  +
  +  /**
  +    * Deletes the given occerance of the trasport property key:value pair
  +    * corresponding to the given key.
  +    *
  +    * This method does not advance the iterator in line with the deletes done.
  +    * In case you want to access the trasport properties after using this
  +    * method, it is advisable to reinitialize the iterator using
  +    * getFirstTrasportPropertyKey();
  +    * However you can use this method despite where the iterator is 
  +    * pointing currently.
  +    *
  +    * @param pcKey Key of the trasport property key:value pair to be deleted
  +    *              If the given key is not set currently, nothing will happen.
  +    * @param uiOccurance Which occerance of the key to be deleted, because 
  +    *                    there can be multiple values for the same key. 
  +    *                    Default is to delete the first occurance.
  +    *                    Count starts from 1.
  +    */
  +    virtual void deleteTrasportProperty(char* pcKey, unsigned int uiOccurance = 1) {};
  +
   
   protected:
       /**