ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject cvs commit: ws-axis/c/src/engine/client Stub.cpp
Date Thu, 17 Mar 2005 09:36:26 GMT
samisa      2005/03/17 01:36:26

  Modified:    c/src/engine/client Stub.cpp
  Log:
  Added logic to add '"' around SOAPAction value.
  AXISCPP-531
  
  Revision  Changes    Path
  1.41      +243 -168  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.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- Stub.cpp	4 Mar 2005 20:57:38 -0000	1.40
  +++ Stub.cpp	17 Mar 2005 09:36:26 -0000	1.41
  @@ -27,341 +27,416 @@
   #include "../../soap/apr_base64.h"
   
   AXIS_CPP_NAMESPACE_USE
  -
  -Stub::Stub(const char *pcEndPointUri, AXIS_PROTOCOL_TYPE eProtocol) 
  -:m_pcUsername(NULL), m_pcPassword(NULL)
  +    Stub::Stub (const char *pcEndPointUri, AXIS_PROTOCOL_TYPE eProtocol):
  +m_pcUsername (NULL),
  +m_pcPassword (NULL)
   {
  -    m_pCall = new Call();
  -    m_pCall->setProtocol(eProtocol);
  -    m_pCall->setEndpointURI(pcEndPointUri);
  -    m_pTransport = m_pCall->getTransport();
  +    m_pCall = new Call ();
  +    m_pCall->setProtocol (eProtocol);
  +    m_pCall->setEndpointURI (pcEndPointUri);
  +    m_pTransport = m_pCall->getTransport ();
   
  -	// Initialise m_viCurrentSOAPMethodAttribute to something sensible 
  -	// in case getFirstSOAPMethodAttribute isn't called first.
  -    m_viCurrentSOAPMethodAttribute = m_vSOAPMethodAttributes.begin();
  +    // Initialise m_viCurrentSOAPMethodAttribute to something sensible 
  +    // in case getFirstSOAPMethodAttribute isn't called first.
  +    m_viCurrentSOAPMethodAttribute = m_vSOAPMethodAttributes.begin ();
   }
   
  -Stub::~Stub()
  +Stub::~Stub ()
   {
       delete m_pCall;
  -	m_pCall = NULL;
  +    m_pCall = NULL;
   
  -	unsigned int j=0;
  -    for (j = 0; j < m_vSOAPHeaderBlocks.size(); j++)
  +    unsigned int j = 0;
  +    for (j = 0; j < m_vSOAPHeaderBlocks.size (); j++)
       {
  -	    delete m_vSOAPHeaderBlocks[j];
  -		m_vSOAPHeaderBlocks[j] = NULL;
  +	delete m_vSOAPHeaderBlocks[j];
  +	m_vSOAPHeaderBlocks[j] = NULL;
       }
   
  -    for (j = 0; j < m_vSOAPMethodAttributes.size(); j++)
  +    for (j = 0; j < m_vSOAPMethodAttributes.size (); j++)
       {
  -	    delete m_vSOAPMethodAttributes[j];
  -	    m_vSOAPMethodAttributes[j] = NULL;
  +	delete m_vSOAPMethodAttributes[j];
  +	m_vSOAPMethodAttributes[j] = NULL;
       }
  -    
  -    if(m_pcUsername)
  -        delete [] m_pcUsername;
  -    if(m_pcPassword)
  -        delete [] m_pcPassword;
  +
  +    if (m_pcUsername)
  +	delete[]m_pcUsername;
  +    if (m_pcPassword)
  +	delete[]m_pcPassword;
   }
   
  -void Stub::setEndPoint(const char *pcEndPoint)
  +void
  +Stub::setEndPoint (const char *pcEndPoint)
   {
  -    m_pCall->setEndpointURI(pcEndPoint);
  +    m_pCall->setEndpointURI (pcEndPoint);
   }
   
  -void Stub::setTransportProperty(const char *pcKey, const char *pcValue)
  +void
  +Stub::setTransportProperty (const char *pcKey, const char *pcValue)
   {
       if (m_pTransport)
  -        m_pTransport->setTransportProperty(pcKey, pcValue);
  +    {
  +	if (strcmp (pcKey, "SOAPAction") == 0)	//Samisa: Setting SOAPAction, 
  +	    //may need to add '"' to value - AXISCPP-531
  +	{
  +	    // both "" missing
  +	    if (pcValue
  +		&& (pcValue[0] != '"'
  +		    && pcValue[strlen (pcValue) - 1] != '"'))
  +	    {
  +		char *tempvalue = new char[strlen (pcValue) + 3];
  +		sprintf (tempvalue, "\"%s\"", pcValue);
  +		m_pTransport->setTransportProperty (pcKey, tempvalue);
  +		delete[]tempvalue;
  +	    }
  +	    else if (pcValue && (pcValue[0] != '"'))	//starting '"' missing
  +	    {
  +		char *tempvalue = new char[strlen (pcValue) + 2];
  +		sprintf (tempvalue, "\"%s", pcValue);
  +		m_pTransport->setTransportProperty (pcKey, tempvalue);
  +		delete[]tempvalue;
  +	    }
  +	    else if (pcValue && (pcValue[strlen (pcValue) - 1] != '"'))	// ending '"'
missing
  +	    {
  +		char *tempvalue = new char[strlen (pcValue) + 3];
  +		sprintf (tempvalue, "\"%s\"", pcValue);
  +		m_pTransport->setTransportProperty (pcKey, tempvalue);
  +		delete[]tempvalue;
  +	    }
  +	    else		// both "" present
  +		m_pTransport->setTransportProperty (pcKey, pcValue);
  +	}
  +	else
  +	{
  +	    m_pTransport->setTransportProperty (pcKey, pcValue);
  +	}
  +    }
   }
   
  -const char* Stub::getTransportProperty(const char *key, bool response) 
  +const char *
  +Stub::getTransportProperty (const char *key, bool response)
   {
  -	return m_pCall->getTransportProperty(key,response);
  +    return m_pCall->getTransportProperty (key, response);
   }
   
  -const char* Stub::getFirstTransportPropertyKey()
  +const char *
  +Stub::getFirstTransportPropertyKey ()
   {
       if (m_pTransport)
  -        return m_pTransport->getFirstTransportPropertyKey();
  +	return m_pTransport->getFirstTransportPropertyKey ();
       else
  -        return NULL;
  +	return NULL;
   }
   
  -const char* Stub::getNextTransportPropertyKey()
  +const char *
  +Stub::getNextTransportPropertyKey ()
   {
       if (m_pTransport)
  -        return m_pTransport->getNextTransportPropertyKey();
  +	return m_pTransport->getNextTransportPropertyKey ();
       else
  -        return NULL;
  +	return NULL;
   }
   
  -const char* Stub::getCurrentTransportPropertyKey()
  +const char *
  +Stub::getCurrentTransportPropertyKey ()
   {
       if (m_pTransport)
  -        return m_pTransport->getCurrentTransportPropertyKey();
  +	return m_pTransport->getCurrentTransportPropertyKey ();
       else
  -        return NULL;
  +	return NULL;
   }
   
  -const char* Stub::getCurrentTransportPropertyValue()
  +const char *
  +Stub::getCurrentTransportPropertyValue ()
   {
       if (m_pTransport)
  -        return m_pTransport->getCurrentTransportPropertyValue();
  +	return m_pTransport->getCurrentTransportPropertyValue ();
       else
  -        return NULL;
  +	return NULL;
   }
   
  -void Stub::deleteCurrentTransportProperty()
  +void
  +Stub::deleteCurrentTransportProperty ()
   {
       if (m_pTransport)
  -        m_pTransport->deleteCurrentTransportProperty();
  +	m_pTransport->deleteCurrentTransportProperty ();
   }
   
  -void Stub::deleteTransportProperty(char* pcKey, unsigned int uiOccurance)
  +void
  +Stub::deleteTransportProperty (char *pcKey, unsigned int uiOccurance)
   {
       if (m_pTransport)
  -        m_pTransport->deleteTransportProperty(pcKey, uiOccurance);
  +	m_pTransport->deleteTransportProperty (pcKey, uiOccurance);
   }
   
  -void Stub::setHandlerProperty(AxisChar* name, void* value, int len)
  +void
  +Stub::setHandlerProperty (AxisChar * name, void *value, int len)
   {
  -	m_pCall->setHandlerProperty(name, value, len);
  +    m_pCall->setHandlerProperty (name, value, len);
   }
   
  -IHeaderBlock* Stub::createSOAPHeaderBlock(AxisChar * pachLocalName,
  -                                           AxisChar * pachUri)
  +IHeaderBlock *
  +Stub::createSOAPHeaderBlock (AxisChar * pachLocalName, AxisChar * pachUri)
   {
  -   if (pachLocalName && pachUri)
  -   {       
  -       if ((AxisUtils::isStringOnlyWithSpaces(pachLocalName)) || 
  -           (AxisUtils::isStringOnlyWithSpaces(pachUri)) )
  -        {
  -            return NULL;
  -        }
  -        else 
  -        {
  -	        IHeaderBlock *pNewSoapheader = m_pCall->createHeaderBlock(pachLocalName, pachUri);
  -	        m_vSOAPHeaderBlocks.push_back(pNewSoapheader);
  -	        return pNewSoapheader;
  -        }
  +    if (pachLocalName && pachUri)
  +    {
  +	if ((AxisUtils::isStringOnlyWithSpaces (pachLocalName)) ||
  +	    (AxisUtils::isStringOnlyWithSpaces (pachUri)))
  +	{
  +	    return NULL;
  +	}
  +	else
  +	{
  +	    IHeaderBlock *pNewSoapheader =
  +		m_pCall->createHeaderBlock (pachLocalName, pachUri);
  +	    m_vSOAPHeaderBlocks.push_back (pNewSoapheader);
  +	    return pNewSoapheader;
  +	}
  +    }
  +    else
  +    {
  +	return NULL;
       }
  -   else {
  -	   return NULL;
  -   }
   }
   
  -IHeaderBlock* Stub::getFirstSOAPHeaderBlock()
  +IHeaderBlock *
  +Stub::getFirstSOAPHeaderBlock ()
   {
  -    m_viCurrentSOAPHeaderBlock = m_vSOAPHeaderBlocks.begin();
  -    if ( m_viCurrentSOAPHeaderBlock == m_vSOAPHeaderBlocks.end())
  -        return NULL;
  +    m_viCurrentSOAPHeaderBlock = m_vSOAPHeaderBlocks.begin ();
  +    if (m_viCurrentSOAPHeaderBlock == m_vSOAPHeaderBlocks.end ())
  +	return NULL;
       else
  -        return (*m_viCurrentSOAPHeaderBlock);
  -    
  +	return (*m_viCurrentSOAPHeaderBlock);
  +
   }
   
  -IHeaderBlock* Stub::getNextSOAPHeaderBlock()
  +IHeaderBlock *
  +Stub::getNextSOAPHeaderBlock ()
   {
       //already at the end?
  -    if ( m_viCurrentSOAPHeaderBlock == m_vSOAPHeaderBlocks.end())
  -        return NULL;
  +    if (m_viCurrentSOAPHeaderBlock == m_vSOAPHeaderBlocks.end ())
  +	return NULL;
   
       m_viCurrentSOAPHeaderBlock++;
  -    if ( m_viCurrentSOAPHeaderBlock == m_vSOAPHeaderBlocks.end())
  -        return NULL;
  +    if (m_viCurrentSOAPHeaderBlock == m_vSOAPHeaderBlocks.end ())
  +	return NULL;
       else
  -        return (*m_viCurrentSOAPHeaderBlock);
  -    
  +	return (*m_viCurrentSOAPHeaderBlock);
  +
   }
   
  -IHeaderBlock* Stub::getCurrentSOAPHeaderBlock()
  +IHeaderBlock *
  +Stub::getCurrentSOAPHeaderBlock ()
   {
  -    if(m_viCurrentSOAPHeaderBlock != m_vSOAPHeaderBlocks.end())
  +    if (m_viCurrentSOAPHeaderBlock != m_vSOAPHeaderBlocks.end ())
       {
  -        return (*m_viCurrentSOAPHeaderBlock);
  +	return (*m_viCurrentSOAPHeaderBlock);
       }
  -	return NULL;
  +    return NULL;
   }
   
  -void Stub::deleteCurrentSOAPHeaderBlock()
  +void
  +Stub::deleteCurrentSOAPHeaderBlock ()
   {
  -    if(m_viCurrentSOAPHeaderBlock != m_vSOAPHeaderBlocks.end())
  +    if (m_viCurrentSOAPHeaderBlock != m_vSOAPHeaderBlocks.end ())
       {
  -        delete(*m_viCurrentSOAPHeaderBlock);
  -        m_vSOAPHeaderBlocks.erase(m_viCurrentSOAPHeaderBlock);
  +	delete (*m_viCurrentSOAPHeaderBlock);
  +	m_vSOAPHeaderBlocks.erase (m_viCurrentSOAPHeaderBlock);
       }
   }
   
  -void Stub::deleteSOAPHeaderBlock(IHeaderBlock* pHeaderBlock)
  +void
  +Stub::deleteSOAPHeaderBlock (IHeaderBlock * pHeaderBlock)
   {
  -    vector <IHeaderBlock *>::iterator currentSOAPHeaderBlock = m_vSOAPHeaderBlocks.begin();
  +    vector < IHeaderBlock * >::iterator currentSOAPHeaderBlock =
  +	m_vSOAPHeaderBlocks.begin ();
       bool bDone = false;
  -    while( !bDone && currentSOAPHeaderBlock != m_vSOAPHeaderBlocks.end())
  +    while (!bDone && currentSOAPHeaderBlock != m_vSOAPHeaderBlocks.end ())
       {
  -        if(pHeaderBlock == *currentSOAPHeaderBlock)
  -        {
  -            delete(*currentSOAPHeaderBlock);
  -            m_vSOAPHeaderBlocks.erase(currentSOAPHeaderBlock);
  -            bDone = true;
  -        }
  -            currentSOAPHeaderBlock++;
  +	if (pHeaderBlock == *currentSOAPHeaderBlock)
  +	{
  +	    delete (*currentSOAPHeaderBlock);
  +	    m_vSOAPHeaderBlocks.erase (currentSOAPHeaderBlock);
  +	    bDone = true;
  +	}
  +	currentSOAPHeaderBlock++;
       }
   }
   
  -void Stub::setSOAPHeaders()
  +void
  +Stub::setSOAPHeaders ()
   {
       SoapSerializer *pSerializer = NULL;
       if (m_pCall)
  -	pSerializer = m_pCall->getSOAPSerializer();
  +	pSerializer = m_pCall->getSOAPSerializer ();
       if (pSerializer)
       {
  -		for (unsigned int i = 0; i < m_vSOAPHeaderBlocks.size(); i++)
  -		{
  -			pSerializer->addHeaderBlock(m_vSOAPHeaderBlocks[i]);
  -		}
  +	for (unsigned int i = 0; i < m_vSOAPHeaderBlocks.size (); i++)
  +	{
  +	    pSerializer->addHeaderBlock (m_vSOAPHeaderBlocks[i]);
  +	}
       }
   }
   
  -void Stub::applyUserPreferences()
  +void
  +Stub::applyUserPreferences ()
   {
  -    setSOAPHeaders();
  +    setSOAPHeaders ();
   }
   
  -void Stub::setProxy(const char* pcProxyHost, unsigned int uiProxyPort)
  +void
  +Stub::setProxy (const char *pcProxyHost, unsigned int uiProxyPort)
   {
  -    m_pCall->setProxy(pcProxyHost, uiProxyPort);
  +    m_pCall->setProxy (pcProxyHost, uiProxyPort);
   }
   
  -void Stub::setTransportTimeout(const long lSeconds)
  +void
  +Stub::setTransportTimeout (const long lSeconds)
   {
       if (m_pTransport)
       {
  -        m_pTransport->setTimeout(lSeconds);
  +	m_pTransport->setTimeout (lSeconds);
       }
   }
   
  -int Stub::getStatus()
  +int
  +Stub::getStatus ()
   {
  -    if ( m_pCall==NULL )
  -        return AXIS_SUCCESS;
  +    if (m_pCall == NULL)
  +	return AXIS_SUCCESS;
       else
  -        return m_pCall->getStatus();
  +	return m_pCall->getStatus ();
   }
   
  -void Stub::setMaintainSession(bool bSession)
  +void
  +Stub::setMaintainSession (bool bSession)
   {
       if (m_pTransport)
       {
  -        m_pTransport->setMaintainSession(bSession);
  +	m_pTransport->setMaintainSession (bSession);
       }
   }
   
   
  -void Stub::setTransportProtocol(AXIS_PROTOCOL_TYPE eProtocol)
  +void
  +Stub::setTransportProtocol (AXIS_PROTOCOL_TYPE eProtocol)
   {
       if (m_pCall)
  -        m_pCall->setProtocol(eProtocol);
  +	m_pCall->setProtocol (eProtocol);
   }
   
  -AXIS_PROTOCOL_TYPE Stub::getTransportProtocol()
  +AXIS_PROTOCOL_TYPE
  +Stub::getTransportProtocol ()
   {
       if (m_pCall)
  -        return m_pCall->getProtocol();
  +	return m_pCall->getProtocol ();
       else
  -       return APT_UNKNOWN;
  +	return APT_UNKNOWN;
   }
   
  -IHeaderBlock* Stub::createSOAPHeaderBlock(AxisChar *pachLocalName, AxisChar *pachUri, AxisChar
*pachPrefix)
  +IHeaderBlock *
  +Stub::createSOAPHeaderBlock (AxisChar * pachLocalName, AxisChar * pachUri,
  +			     AxisChar * pachPrefix)
   {
       if (pachLocalName && pachUri && pachPrefix)
       {
  -        if (AxisUtils::isStringOnlyWithSpaces(pachLocalName) || 
  -                AxisUtils::isStringOnlyWithSpaces(pachUri) )
  -        {
  -            return NULL;
  -        }
  -        else 
  -        {
  -	        IHeaderBlock *pNewSoapheader = m_pCall->createHeaderBlock(pachLocalName, pachUri,
pachPrefix);
  -	        m_vSOAPHeaderBlocks.push_back(pNewSoapheader);
  -	        return pNewSoapheader;
  -        }
  -    }
  -    else {
  +	if (AxisUtils::isStringOnlyWithSpaces (pachLocalName) ||
  +	    AxisUtils::isStringOnlyWithSpaces (pachUri))
  +	{
   	    return NULL;
  +	}
  +	else
  +	{
  +	    IHeaderBlock *pNewSoapheader =
  +		m_pCall->createHeaderBlock (pachLocalName, pachUri,
  +					    pachPrefix);
  +	    m_vSOAPHeaderBlocks.push_back (pNewSoapheader);
  +	    return pNewSoapheader;
  +	}
  +    }
  +    else
  +    {
  +	return NULL;
       }
   }
   
  -void Stub::setUsername(const char* pcUsername)
  +void
  +Stub::setUsername (const char *pcUsername)
   {
  -    if(m_pcUsername) 
  +    if (m_pcUsername)
       {
  -        delete [] m_pcUsername;
  -        m_pcUsername = NULL;
  +	delete[]m_pcUsername;
  +	m_pcUsername = NULL;
       }
   
  -    if(!pcUsername)
  -        return;
  +    if (!pcUsername)
  +	return;
   
  -    m_pcUsername = new char[strlen(pcUsername) + 1];
  -    strcpy(m_pcUsername, pcUsername);
  +    m_pcUsername = new char[strlen (pcUsername) + 1];
  +    strcpy (m_pcUsername, pcUsername);
   
       if (m_pcPassword)
       {
  -        setAuthorizationHeader();
  +	setAuthorizationHeader ();
       }
   }
   
  -void Stub::setPassword(const char* pcPassword)
  +void
  +Stub::setPassword (const char *pcPassword)
   {
  -    if(m_pcPassword)
  +    if (m_pcPassword)
       {
  -        delete [] m_pcPassword;
  -        m_pcPassword = NULL;
  +	delete[]m_pcPassword;
  +	m_pcPassword = NULL;
       }
  -    
  -    if(!pcPassword)
  -        return;
   
  -    m_pcPassword = new char[strlen(pcPassword) + 1];
  -    strcpy(m_pcPassword, pcPassword);
  +    if (!pcPassword)
  +	return;
  +
  +    m_pcPassword = new char[strlen (pcPassword) + 1];
  +    strcpy (m_pcPassword, pcPassword);
   
       if (m_pcUsername)
       {
  -        setAuthorizationHeader();
  +	setAuthorizationHeader ();
       }
   }
   
  -const char* Stub::getUsername()
  +const char *
  +Stub::getUsername ()
   {
       return m_pcUsername;
   }
   
  -const char* Stub::getPassword()
  +const char *
  +Stub::getPassword ()
   {
       return m_pcPassword;
   }
   
  -void Stub::setAuthorizationHeader()
  +void
  +Stub::setAuthorizationHeader ()
   {
  -    char* cpUsernamePassword = new char[strlen(m_pcUsername) + strlen(m_pcPassword) + 2];
  -    strcpy( cpUsernamePassword, m_pcUsername );
  -    strcat( cpUsernamePassword, ":" );
  -    strcat( cpUsernamePassword, m_pcPassword );
  -
  -    int len = apr_base64_encode_len (strlen(cpUsernamePassword));
  -    AxisChar* base64Value = new AxisChar[len + 1];
  -    len = apr_base64_encode_binary (base64Value, (const unsigned char*)cpUsernamePassword,
strlen(cpUsernamePassword));
  +    char *cpUsernamePassword =
  +	new char[strlen (m_pcUsername) + strlen (m_pcPassword) + 2];
  +    strcpy (cpUsernamePassword, m_pcUsername);
  +    strcat (cpUsernamePassword, ":");
  +    strcat (cpUsernamePassword, m_pcPassword);
  +
  +    int len = apr_base64_encode_len (strlen (cpUsernamePassword));
  +    AxisChar *base64Value = new AxisChar[len + 1];
  +    len =
  +	apr_base64_encode_binary (base64Value,
  +				  (const unsigned char *) cpUsernamePassword,
  +				  strlen (cpUsernamePassword));
   
       std::string strValue = "Basic ";
       strValue += base64Value;
   
       if (m_pTransport)
  -        m_pTransport->setTransportProperty("Authorization", strValue.c_str());
  +	m_pTransport->setTransportProperty ("Authorization",
  +					    strValue.c_str ());
   
  -    delete [] cpUsernamePassword;
  -    delete [] base64Value;
  +    delete[]cpUsernamePassword;
  +    delete[]base64Value;
   }
  -
  
  
  

Mime
View raw message