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 pr...@apache.org on 2005/02/23 16:31:20 UTC

cvs commit: ws-axis/c/src/soap Attribute.cpp HeaderBlock.h SoapSerializer.cpp SoapSerializer.h HeaderBlock.cpp

prestonf    2005/02/23 07:31:20

  Modified:    c/src/soap Attribute.cpp HeaderBlock.h SoapSerializer.cpp
                        SoapSerializer.h HeaderBlock.cpp
  Log:
  Hi All,
  I think this will complete what needs to be done for AXISCPP-471, AXISCPP-472 and AXISCPP-473.
  
  Regards,
  Fred Preston.
  
  Revision  Changes    Path
  1.34      +1 -1      ws-axis/c/src/soap/Attribute.cpp
  
  Index: Attribute.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/Attribute.cpp,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Attribute.cpp	23 Feb 2005 13:03:48 -0000	1.33
  +++ Attribute.cpp	23 Feb 2005 15:31:20 -0000	1.34
  @@ -179,7 +179,7 @@
   {    
       int intStatus= AXIS_FAIL;
   
  -    if (isSerializable())
  +    if (isSerializable() && !pSZ.getNamespaceURL( m_prefix).empty())
       {        
           pSZ.serialize(" ", NULL);
   
  
  
  
  1.28      +2 -0      ws-axis/c/src/soap/HeaderBlock.h
  
  Index: HeaderBlock.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/HeaderBlock.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- HeaderBlock.h	22 Feb 2005 12:02:30 -0000	1.27
  +++ HeaderBlock.h	23 Feb 2005 15:31:20 -0000	1.28
  @@ -125,6 +125,8 @@
   
       virtual const AxisChar* getAttributeValue(const AxisChar* localname,
            const AxisChar* prefix);
  +    virtual const AxisChar* getAttributeUri( const AxisChar * localname,
  +         const AxisChar* prefix);
       BasicNode* createImmediateChild(NODE_TYPE eNODE_TYPE);
       BasicNode* createChild(NODE_TYPE eNODE_TYPE);
       BasicNode* getLastChild();
  
  
  
  1.99      +136 -44   ws-axis/c/src/soap/SoapSerializer.cpp
  
  Index: SoapSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapSerializer.cpp,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- SoapSerializer.cpp	18 Feb 2005 11:11:19 -0000	1.98
  +++ SoapSerializer.cpp	23 Feb 2005 15:31:20 -0000	1.99
  @@ -243,60 +243,75 @@
   
   int SoapSerializer::setOutputStream(SOAPTransport* pStream)
   {
  +    int	iStatus= AXIS_SUCCESS;
  +
       m_pOutputStream = pStream;
  -    int iStatus= AXIS_SUCCESS;
  +
       try
       {
  -    if(m_pSoapEnvelope)
  -    {
  -		if (checkAttachmentAvailability()) {
  +	    if( m_pSoapEnvelope)
  +		{
  +			if( checkAttachmentAvailability())
  +			{
  +				string	asStartID;
  +				string	asSOAPMimeHeaders;
   
  -            string asStartID;
  -            string asSOAPMimeHeaders;
  -            asSOAPMimeHeaders   = pStream->getIncomingSOAPMimeHeaders();
  -            int start= asSOAPMimeHeaders.find("Content-Type");
  -            int startPosIdValue = asSOAPMimeHeaders.find ("<",start+strlen("Content-Id:"))+1;
  -            int endPosIdValue   = asSOAPMimeHeaders.find(">", start+strlen("Content-Type"));
  -            int length          = endPosIdValue - startPosIdValue ;
  -            asStartID           = asSOAPMimeHeaders.substr (startPosIdValue,length); 
  -        
  -            string * asContentType = new string("multipart/related; type=\"text/xml\"; start=\"<");
  -            *asContentType=*asContentType + asStartID + ">\"";
  -            *asContentType=*asContentType +";  boundary=\"------=MIME BOUNDARY\"";
  -            pStream->setTransportProperty(CONTENT_TYPE, (*asContentType).c_str()); 
  +				asSOAPMimeHeaders = pStream->getIncomingSOAPMimeHeaders();
   
  -			serialize("\n------=MIME BOUNDARY\n", NULL);
  -			serialize(pStream->getIncomingSOAPMimeHeaders(), "\n\n", NULL);
  -		}
  +				int		start			= asSOAPMimeHeaders.find( "Content-Type");
  +				int		startPosIdValue = asSOAPMimeHeaders.find( "<", start + strlen( "Content-Id:")) + 1;
  +				int		endPosIdValue   = asSOAPMimeHeaders.find( ">", start + strlen( "Content-Type"));
  +				int		length          = endPosIdValue - startPosIdValue ;
  +
  +				asStartID = asSOAPMimeHeaders.substr (startPosIdValue,length); 
  +
  +				string *	asContentType = new string( "multipart/related; type=\"text/xml\"; start=\"<");
  +
  +				*asContentType = *asContentType + asStartID + ">\"";
  +				*asContentType = *asContentType + ";  boundary=\"------=MIME BOUNDARY\"";
  +
  +				pStream->setTransportProperty( CONTENT_TYPE, (*asContentType).c_str()); 
   
  -        serialize("<?xml version='1.0' encoding='utf-8' ?>", NULL);
  -        iStatus= m_pSoapEnvelope->serialize(*this, 
  -            (SOAP_VERSION)m_iSoapVersion);		
  -		
  -		if (checkAttachmentAvailability()) {
  -			serialize("\n------=MIME BOUNDARY\n", NULL);
  -			serializeAttachments(*this);
  +				serialize( "\n------=MIME BOUNDARY\n", NULL);
  +				serialize( pStream->getIncomingSOAPMimeHeaders(), "\n\n", NULL);
  +			}
  +
  +			serialize( "<?xml version='1.0' encoding='utf-8' ?>", NULL);
  +
  +			if( (iStatus = m_pSoapEnvelope->serialize( *this, (SOAP_VERSION) m_iSoapVersion)) == AXIS_FAIL)
  +			{
  +				char * pszMsg = new char[128];
  +
  +				strcpy( pszMsg, "The SOAP serialiser has detected errors in the header or envelope.  Transmission has been aborted.");
  +
  +				throw AxisSoapException( CLIENT_SOAP_MESSAGE_INCOMPLETE, pszMsg);
  +			}
  +
  +			if( checkAttachmentAvailability())
  +			{
  +				serialize( "\n------=MIME BOUNDARY\n", NULL);
  +				serializeAttachments( *this);
  +			}
   		}
  +	}
  +	catch( AxisSoapException& e)
  +	{
  +		e = e;
   
  -    }
  -    }
  -    catch(AxisSoapException& e)
  -    {
  -        e = e;
  +		throw;
  +	}
  +	catch( AxisException& e)
  +	{
  +		e = e;
   
  -        throw;
  -    }
  -    catch(AxisException& e)
  -    {
  -        e = e;
  +		throw;
  +	}
  +	catch( ...)
  +	{
  +		throw;
  +	}
   
  -        throw;
  -    }
  -    catch(...)
  -    {
  -        throw;
  -    }
  -    return iStatus;
  +	return iStatus;
   }
   
   /*
  @@ -1163,4 +1178,81 @@
   {
   	return m_pSoapEnvelope->m_pSoapHeader->getCurrentHeaderBlock();
   }
  +
  +AxisXMLString SoapSerializer::getNamespaceURL( string sNameSpace)
  +{
  +// Check that the namespace value is not empty.  If it is then return as
  +// there is nothing to do!
  +	if( sNameSpace.empty())
  +	{
  +		return "nothing to do";
  +	}
  +
  +// Iterate through the namespace stack.  If the namespace can be found, then
  +// return the associated uri.
  +	map <AxisXMLString, AxisXMLString>::iterator	iterator = m_NsStack.begin();
  +
  +	while( iterator != m_NsStack.end())
  +	{
  +		AxisXMLString	sIt_URI = iterator->first;
  +		AxisXMLString	sIt_NameSpace = iterator->second;
  +
  +		if( sNameSpace == sIt_NameSpace)
  +		{
  +			return iterator->first;
  +		}
  +		else
  +		{
  +			iterator++;
  +		}
  +	}
  +
  +// Couldn't find the namespace in the namespace list.  Try trawling through the
  +// SOAP headers looking to see if any of their children have defined any
  +// namespaces.
  +	IHeaderBlock *	pHeaderBlock = m_pSoapEnvelope->m_pSoapHeader->getFirstHeaderBlock();
  +
  +	while( pHeaderBlock != NULL)
  +	{
  +		for( int iChildIndex = 0; iChildIndex < pHeaderBlock->getNoOfChildren(); iChildIndex++)
  +		{
  +			BasicNode *	pChild = pHeaderBlock->getChild( iChildIndex + 1);
  +
  +			if( pChild != NULL)
  +			{
  +				if( !strcmp( sNameSpace.c_str(), pChild->getPrefix()))
  +				{
  +					return pChild->getURI();
  +				}
  +			}
  +		}
  +
  +		pHeaderBlock = m_pSoapEnvelope->m_pSoapHeader->getNextHeaderBlock();
  +	}
  +
  +// Couldn't find the namespace in the namespace list or in children.  Try
  +// trawling through the SOAP headers looking to see if any of their attributes
  +// have defined any namespaces.
  +	char *	pszNameSpace = (char *) sNameSpace.c_str();
  +	char *	pszValue = NULL;
  +
  +	pHeaderBlock = m_pSoapEnvelope->m_pSoapHeader->getFirstHeaderBlock();
  +
  +	while( pHeaderBlock != NULL && pszValue == NULL)
  +	{
  +		pszValue = (char *) pHeaderBlock->getAttributeUri( "", pszNameSpace);
  +
  +		pHeaderBlock = m_pSoapEnvelope->m_pSoapHeader->getNextHeaderBlock();
  +	}
  +
  +	if( pszValue == NULL)
  +	{
  +		return "";
  +	}
  +	else
  +	{
  +		return pszValue;
  +	}
  +}
  +
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.42      +1 -1      ws-axis/c/src/soap/SoapSerializer.h
  
  Index: SoapSerializer.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapSerializer.h,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- SoapSerializer.h	3 Feb 2005 05:10:21 -0000	1.41
  +++ SoapSerializer.h	23 Feb 2005 15:31:20 -0000	1.42
  @@ -210,7 +210,7 @@
   	int addOutputAnyObject(AnyType* pAnyObject);
   	int serializeAnyObject(AnyType* pAnyObject);
       int serializeAsChardata(void* pValue, XSDTYPE type);
  -
  +	AxisXMLString getNamespaceURL( string sNameSpace);
   };
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.55      +37 -8     ws-axis/c/src/soap/HeaderBlock.cpp
  
  Index: HeaderBlock.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/HeaderBlock.cpp,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- HeaderBlock.cpp	23 Feb 2005 14:04:33 -0000	1.54
  +++ HeaderBlock.cpp	23 Feb 2005 15:31:20 -0000	1.55
  @@ -369,26 +369,30 @@
   }
   
   int HeaderBlock::serializeChildren(SoapSerializer& pSZ,
  -                                   list<AxisChar*>& lstTmpNameSpaceStack)
  +                                   list<AxisChar *>& lstTmpNameSpaceStack)
   {
  -	// soapserialiser does not have an == operator so can't check it
  -    list<BasicNode*>::iterator itCurrBasicNode= m_children.begin();
  +    int iStatus = AXIS_SUCCESS;
  +
  +// SOAP serialiser does not have an == operator so can't check it
  +    list<BasicNode*>::iterator itCurrBasicNode = m_children.begin();
   
  -    while(itCurrBasicNode != m_children.end())
  +    while( itCurrBasicNode != m_children.end() && iStatus == AXIS_SUCCESS)
       {
           if ((*itCurrBasicNode)->getNodeType() == ELEMENT_NODE)
           {
  -            (*itCurrBasicNode)->serialize(pSZ, lstTmpNameSpaceStack);
  +// Processing for ELEMENT_NODE types
  +            iStatus = (*itCurrBasicNode)->serialize( pSZ, lstTmpNameSpaceStack);
           }
           else
           {
  -            /* for CHARACTER_NODE types */
  -            (*itCurrBasicNode)->serialize(pSZ);
  +// Processing for CHARACTER_NODE types
  +            iStatus = (*itCurrBasicNode)->serialize( pSZ);
           }
  +
           itCurrBasicNode++;
       }
   
  -    return AXIS_SUCCESS;
  +    return iStatus;
   }
   
   INamespace* HeaderBlock::createNamespaceDecl(const AxisChar *prefix,
  @@ -726,7 +730,32 @@
       return NULL;
   }
    
  +const AxisChar * HeaderBlock::getAttributeUri( const AxisChar * localname,
  +											   const AxisChar * prefix)
  +{
  +	list<Attribute*>::iterator itAttr = m_attributes.begin();
   
  +	while( itAttr != m_attributes.end()) 
  +	{
  +		Attribute * pAttribute = *itAttr;
  +
  +		if( !strcmp( pAttribute->getLocalName(),localname) &&
  +			!strcmp( pAttribute->getPrefix(),prefix)) 
  +		{
  +			return pAttribute->getURI();
  +		}
  +		
  +		if( strlen( localname) == 0 &&
  +			!strcmp( pAttribute->getPrefix(), prefix)) 
  +		{
  +			return pAttribute->getURI();
  +		}
  +
  +		itAttr++;
  +	}
  +
  +	return NULL;
  +}
   
   BasicNode* HeaderBlock::createImmediateChild(NODE_TYPE eNODE_TYPE,
                                                AxisChar *pachLocalName,