axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r383942 [3/3] - in /webservices/axis/trunk/c/src/soap: SoapDeSerializer.cpp SoapSerializer.cpp
Date Tue, 07 Mar 2006 17:54:36 GMT
Modified: webservices/axis/trunk/c/src/soap/SoapSerializer.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/soap/SoapSerializer.cpp?rev=383942&r1=383941&r2=383942&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/soap/SoapSerializer.cpp (original)
+++ webservices/axis/trunk/c/src/soap/SoapSerializer.cpp Tue Mar  7 09:54:36 2006
@@ -47,7 +47,7 @@
 #include "../common/AxisConfig.h"
 
 extern AXIS_CPP_NAMESPACE_PREFIX AxisConfig* g_pConfig;
-#define MIMEBOUNDARY	"------=MIME_BOUNDARY"
+#define MIMEBOUNDARY    "------=MIME_BOUNDARY"
 
 AXIS_CPP_NAMESPACE_START
 
@@ -56,33 +56,33 @@
     m_pSoapEnvelope = NULL;
     m_iSoapVersion = SOAP_VER_1_1;
     m_pOutputStream = NULL;
-	m_pNamespace = NULL;
-	m_pContentIdSet = NULL;
+    m_pNamespace = NULL;
+    m_pContentIdSet = NULL;
 }
 
 SoapSerializer::~SoapSerializer()
 {
     if( m_pSoapEnvelope)
-	{
-		delete m_pSoapEnvelope;
-	}
-
-	/* Cleaning the memory allocated to the SoapAttachments */       
-	map<AxisXMLString, ISoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
-	while( itCurrAttach != m_SoapAttachments.end())
+    {
+        delete m_pSoapEnvelope;
+    }
+
+    /* Cleaning the memory allocated to the SoapAttachments */       
+    map<AxisXMLString, ISoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
+    while( itCurrAttach != m_SoapAttachments.end())
     {        
-        delete( (SoapAttachment*)((*itCurrAttach).second));		
+        delete( (SoapAttachment*)((*itCurrAttach).second));        
         itCurrAttach++;
     }
-	m_SoapAttachments.clear();
+    m_SoapAttachments.clear();
 
-	list<SoapAttachmentReference*>::iterator itAttRef= m_attachmentRefs.begin();
-	while(itAttRef != m_attachmentRefs.end())
+    list<SoapAttachmentReference*>::iterator itAttRef= m_attachmentRefs.begin();
+    while(itAttRef != m_attachmentRefs.end())
     {        
         delete *itAttRef;
         itAttRef++;
     }
-	m_attachmentRefs.clear();
+    m_attachmentRefs.clear();
 }
 
 int SoapSerializer::setSoapEnvelope( SoapEnvelope * pSoapEnvelope)
@@ -98,16 +98,12 @@
 
     if( m_pSoapEnvelope)
     {
-
+        /* no need to create a SOAP Header, it already exists */
         if( (m_pSoapEnvelope) && (m_pSoapEnvelope->m_pSoapHeader))
-        {
-            /* no need to create a SOAP Header, it already exists */
             intStatus = AXIS_OBJECT_ALREADY_EXISTS;
-        }
         else
         {
             m_pSoapEnvelope->setSoapHeader( pSoapHeader);
-
             intStatus= AXIS_SUCCESS;
         }
     }
@@ -122,7 +118,6 @@
     if(m_pSoapEnvelope)
     {
         m_pSoapEnvelope->setSoapBody( pSoapBody);
-
         intStatus = AXIS_SUCCESS;
     }
 
@@ -135,12 +130,10 @@
 
     if( m_pSoapEnvelope && (m_pSoapEnvelope->m_pSoapBody))
     {
-		if( !(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
-		{
-			m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod = pSoapMethod;
-		}
-			
-		intStatus = AXIS_SUCCESS;
+        if( !(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
+            m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod = pSoapMethod;
+            
+        intStatus = AXIS_SUCCESS;
     }
 
     return intStatus;
@@ -150,7 +143,7 @@
                                               XSDTYPE nType,
                                               const AxisChar * pName)
 {
-	int	iSuccess = AXIS_SUCCESS;
+    int    iSuccess = AXIS_SUCCESS;
 
     Axis_Array * pLocalArray = pArray->clone();
 
@@ -168,7 +161,6 @@
     delete pLocalArray;
     pLocalArray = NULL;
 
-
     Param* pParam = new Param();
 
     if( RPC_ENCODED == m_nStyle)
@@ -187,27 +179,25 @@
 
     if( m_pSoapEnvelope && (m_pSoapEnvelope->m_pSoapBody) && 
         (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
-    {
         m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addOutputParam( pParam);
-    }
 
     return iSuccess;  // Can it only be successful?
 }
 
 int SoapSerializer::addOutputCmplxArrayParam( const Axis_Array * pArray, 
                                               void * pSZFunct,
-											  void * pDelFunct,
+                                              void * pDelFunct,
                                               void * pSizeFunct, 
                                               const AxisChar * pName, 
                                               const AxisChar * pNamespace)
 {
-	int	iSuccess = AXIS_SUCCESS;
+    int    iSuccess = AXIS_SUCCESS;
 
     Axis_Array * pLocalArray = pArray->clone();
 
     ArrayBean* pAb = makeArrayBean( pLocalArray->m_Array, pSZFunct,
-									 pDelFunct,
-									 pSizeFunct);
+                                     pDelFunct,
+                                     pSizeFunct);
 
     pAb->SetDimension( pLocalArray->m_Size);
     
@@ -234,10 +224,8 @@
     {
         pAb->SetItemName( pName);
 
-	    if( NULL != pNamespace)
-		{
-		    pParam->setURI( pNamespace);
-		}
+        if( NULL != pNamespace)
+            pParam->setURI( pNamespace);
 
         pParam->setName( "array");        
     }
@@ -246,11 +234,9 @@
     pParam->m_Type = XSD_ARRAY;
 
     if( m_pSoapEnvelope &&
-		(m_pSoapEnvelope->m_pSoapBody) &&
-		(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
-    {
+        (m_pSoapEnvelope->m_pSoapBody) &&
+        (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
         m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addOutputParam( pParam);
-    }
 
     pParam->setName( pName);
 
@@ -258,12 +244,12 @@
 }
 
 int SoapSerializer::addOutputCmplxParam( void * pObject,
-										 void * pSZFunct, 
+                                         void * pSZFunct, 
                                          void * pDelFunct,
-										 const AxisChar * pName,
+                                         const AxisChar * pName,
                                          const AxisChar * pNamespace)
 { 
-	int	iSuccess = AXIS_SUCCESS;
+    int    iSuccess = AXIS_SUCCESS;
 
     Param * pParam = new Param();
 
@@ -271,26 +257,23 @@
     pParam->m_Value.pCplxObj->pObject = pObject;
     pParam->m_Value.pCplxObj->pSZFunct = (AXIS_SERIALIZE_FUNCT) pSZFunct;
     pParam->m_Value.pCplxObj->pDelFunct = (AXIS_OBJECT_DELETE_FUNCT) pDelFunct;
-	if( m_pSoapEnvelope &&
-		(m_pSoapEnvelope->m_pSoapBody) &&
-		(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
-    {
+    if( m_pSoapEnvelope &&
+        (m_pSoapEnvelope->m_pSoapBody) &&
+        (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
         m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addOutputParam( pParam);
-    }
 
     pParam->setName( pName);
     
-
     return iSuccess;  // Can it only be successful?
 }
 
 int SoapSerializer::addFaultDetail( void * pObject,
-								    void * pSZFunct, 
+                                    void * pSZFunct, 
                                     void * pDelFunct,
-									const AxisChar * pName,
+                                    const AxisChar * pName,
                                     const AxisChar * pNamespace)
 { 
-	int	iSuccess = AXIS_SUCCESS;
+    int    iSuccess = AXIS_SUCCESS;
     Param * pParam = new Param();
 
     pParam->m_Value.pCplxObj = new ComplexObjectHandler;
@@ -299,11 +282,9 @@
     pParam->m_Value.pCplxObj->pDelFunct = (AXIS_OBJECT_DELETE_FUNCT) pDelFunct;
 
     if( m_pSoapEnvelope &&
-		(m_pSoapEnvelope->m_pSoapBody) &&
-		(m_pSoapEnvelope->m_pSoapBody->m_pSoapFault)) 
-    {
+        (m_pSoapEnvelope->m_pSoapBody) &&
+        (m_pSoapEnvelope->m_pSoapBody->m_pSoapFault)) 
         iSuccess = m_pSoapEnvelope->m_pSoapBody->m_pSoapFault->setFaultDetail(pParam);
-    }
 
     pParam->setName( pName);
 
@@ -316,11 +297,10 @@
 
     if( m_pSoapEnvelope && (m_pSoapEnvelope->m_pSoapBody))
     {
-		if(m_pSoapEnvelope->m_pSoapBody->m_pSoapFault)
-			delete m_pSoapEnvelope->m_pSoapBody->m_pSoapFault;
+        if(m_pSoapEnvelope->m_pSoapBody->m_pSoapFault)
+            delete m_pSoapEnvelope->m_pSoapBody->m_pSoapFault;
 
         m_pSoapEnvelope->m_pSoapBody->m_pSoapFault = pSoapFault;
-
         intStatus = AXIS_SUCCESS;
     }
 
@@ -329,91 +309,85 @@
 
 int SoapSerializer::setOutputStream( SOAPTransport * pStream)
 {
-    int	iStatus = AXIS_SUCCESS;
+    int    iStatus = AXIS_SUCCESS;
 
     m_pOutputStream = pStream;
 
     try
     {
-	    if( m_pSoapEnvelope)
-		{
-			if( checkAttachmentAvailability())
-			{
-				char *pszSOAPMimeHeaders = pStream->getIncomingSOAPMimeHeaders();
-				if (NULL != pszSOAPMimeHeaders) 
-				{	// Server code
-					string asSOAPMimeHeaders = pszSOAPMimeHeaders;
-					int		start			= asSOAPMimeHeaders.find( AXIS_CONTENT_TYPE);
-					int		startPosIdValue = asSOAPMimeHeaders.find( "<", start + strlen( AXIS_CONTENT_ID
":")) + 1;
-					int		endPosIdValue   = asSOAPMimeHeaders.find( ">", start + strlen( AXIS_CONTENT_TYPE));
-					int		length          = endPosIdValue - startPosIdValue ;	
-
-					string asStartID = asSOAPMimeHeaders.substr (startPosIdValue,length); 
-
-					string asContentType( "multipart/related; type=\"text/xml\"; start=\"<");
-
-					asContentType = asContentType + asStartID + ">\"";
-					asContentType = asContentType + ";  boundary=\"" MIMEBOUNDARY "\"";
-
-					pStream->setTransportProperty( CONTENT_TYPE, asContentType.c_str()); 
-
-					serialize( "\r\n" MIMEBOUNDARY "\r\n", NULL);
-					serialize( pStream->getIncomingSOAPMimeHeaders(), "\r\n\r\n", NULL);
-				}
-				else
-				{	// Client code
-					const char *id = m_pContentIdSet->generateId();
-					string ctype = "multipart/related; type=\"text/xml\"; boundary=\"";
-					ctype += MIMEBOUNDARY;
-					ctype += "\"; start=\"<";
-					ctype += id;
-					ctype += ">\"";
-					pStream->deleteTransportProperty(AXIS_CONTENT_TYPE); // Never want 2 Content-Type
HTTP headers
-					pStream->setTransportProperty(AXIS_CONTENT_TYPE, ctype.c_str());
+        if( m_pSoapEnvelope)
+        {
+            if( checkAttachmentAvailability())
+            {
+                char *pszSOAPMimeHeaders = pStream->getIncomingSOAPMimeHeaders();
+                if (NULL != pszSOAPMimeHeaders) 
+                {    // Server code
+                    string asSOAPMimeHeaders = pszSOAPMimeHeaders;
+                    int        start            = asSOAPMimeHeaders.find( AXIS_CONTENT_TYPE);
+                    int        startPosIdValue = asSOAPMimeHeaders.find( "<", start +
strlen( AXIS_CONTENT_ID ":")) + 1;
+                    int        endPosIdValue   = asSOAPMimeHeaders.find( ">", start +
strlen( AXIS_CONTENT_TYPE));
+                    int        length          = endPosIdValue - startPosIdValue ;    
+
+                    string asStartID = asSOAPMimeHeaders.substr (startPosIdValue,length);

+
+                    string asContentType( "multipart/related; type=\"text/xml\"; start=\"<");
+
+                    asContentType = asContentType + asStartID + ">\"";
+                    asContentType = asContentType + ";  boundary=\"" MIMEBOUNDARY "\"";
+
+                    pStream->setTransportProperty( CONTENT_TYPE, asContentType.c_str());

+
+                    serialize( "\r\n" MIMEBOUNDARY "\r\n", NULL);
+                    serialize( pStream->getIncomingSOAPMimeHeaders(), "\r\n\r\n", NULL);
+                }
+                else
+                {    // Client code
+                    const char *id = m_pContentIdSet->generateId();
+                    string ctype = "multipart/related; type=\"text/xml\"; boundary=\"";
+                    ctype += MIMEBOUNDARY;
+                    ctype += "\"; start=\"<";
+                    ctype += id;
+                    ctype += ">\"";
+                    pStream->deleteTransportProperty(AXIS_CONTENT_TYPE); // Never want
2 Content-Type HTTP headers
+                    pStream->setTransportProperty(AXIS_CONTENT_TYPE, ctype.c_str());
 
-					serialize("\r\n--" MIMEBOUNDARY "\r\n", NULL);
+                    serialize("\r\n--" MIMEBOUNDARY "\r\n", NULL);
                     serialize(AXIS_CONTENT_TYPE ": text/xml; charset=UTF-8\r\n", NULL);
                     serialize(AXIS_CONTENT_TRANSFER_ENCODING ": binary\r\n", NULL);
 
-					string cid = AXIS_CONTENT_ID;
-					cid += ": <";
-					cid += id;
-					cid += ">\r\n\r\n";		// Extra \r\n terminates headers
+                    string cid = AXIS_CONTENT_ID;
+                    cid += ": <";
+                    cid += id;
+                    cid += ">\r\n\r\n";        // Extra \r\n terminates headers
                     serialize(cid.c_str(), NULL);
-				}
-			}
+                }
+            }
+
+            serialize( "<?xml version='1.0' encoding='utf-8' ?>", NULL);
 
-			serialize( "<?xml version='1.0' encoding='utf-8' ?>", NULL);
+            if( (iStatus = m_pSoapEnvelope->serialize( *this, (SOAP_VERSION) m_iSoapVersion))
== AXIS_FAIL)
+                throw AxisSoapException( CLIENT_SOAP_MESSAGE_INCOMPLETE, "The SOAP serializer
has detected errors in the header or envelope. Transmission has been aborted.");
 
-			if( (iStatus = m_pSoapEnvelope->serialize( *this, (SOAP_VERSION) m_iSoapVersion)) ==
AXIS_FAIL)
-			{
-				throw AxisSoapException( CLIENT_SOAP_MESSAGE_INCOMPLETE, "The SOAP serializer has detected
errors in the header or envelope. Transmission has been aborted.");
-			}
-
-			if( checkAttachmentAvailability())
-			{
-				serializeAttachments( *this);
-			}
-		}
-	}
-	catch( AxisSoapException& e)
-	{
-		e = e;
-
-		throw;
-	}
-	catch( AxisException& e)
-	{
-		e = e;
-
-		throw;
-	}
-	catch( ...)
-	{
-		throw;
-	}
+            if( checkAttachmentAvailability())
+                serializeAttachments( *this);
+        }
+    }
+    catch( AxisSoapException& e)
+    {
+        e = e;
+        throw;
+    }
+    catch( AxisException& e)
+    {
+        e = e;
+        throw;
+    }
+    catch( ...)
+    {
+        throw;
+    }
 
-	return iStatus;
+    return iStatus;
 }
 
 /*
@@ -437,7 +411,6 @@
     if( m_pSoapEnvelope)
     {
         delete m_pSoapEnvelope;
-
         m_pSoapEnvelope= NULL;
     }
 
@@ -473,9 +446,7 @@
 void SoapSerializer::removeNamespacePrefix( const AxisChar * pNamespace)
 {
     if( m_NsStack.find( pNamespace) != m_NsStack.end())
-    {
         m_NsStack.erase( pNamespace);
-    }
 }
 
 const AxisChar * SoapSerializer::getNamespacePrefix( const AxisChar * pNamespace)
@@ -483,9 +454,7 @@
     if( m_NsStack.find( pNamespace) == m_NsStack.end())
     {
         m_nCounter++;
-
         AxisSprintf(m_Buf, 8, "ns%d", m_nCounter);
-
         m_NsStack[pNamespace] = m_Buf;
     }
 
@@ -498,11 +467,8 @@
     if( m_NsStack.find( pNamespace) == m_NsStack.end())
     {
         m_nCounter++;
-
         AxisSprintf(m_Buf, 8, "ns%d", m_nCounter);
-
         m_NsStack[pNamespace] = m_Buf;
-
         blnIsNewPrefix = true;
     }
 
@@ -511,28 +477,23 @@
 
 IWrapperSoapSerializer& SoapSerializer::operator << (const AxisChar * cSerialized)
 {
+	// some thing has gone wrong. So do nothing 
     if( AXIS_SUCCESS != m_nStatus) 
-    {
-        // some thing has gone wrong. So do nothing 
         return *this;
-    }
 
     try
     {
       // send everything to transport layer, it should handle bufferization itself 
       m_pOutputStream->sendBytes( cSerialized, 0);
-
     }
     catch(AxisSoapException& e)
     {
         e = e;
-
         throw;
     }
     catch(AxisException& e)
     {
         e = e;
-
         throw;
     }
     catch(...)
@@ -567,8 +528,8 @@
 
 int SoapSerializer::createSoapFault( const AxisChar * sLocalName, 
                                      const AxisChar * sURI,
-								     const AxisChar * sFaultCode,
-								     const AxisChar * sFaultString)
+                                     const AxisChar * sFaultCode,
+                                     const AxisChar * sFaultString)
 {
     SoapFault * pSoapFault = new SoapFault();
 
@@ -609,9 +570,9 @@
  * of complex types
  */
 ArrayBean * SoapSerializer::makeArrayBean(void ** pObject,
-										   void * pSZFunct, 
+                                           void * pSZFunct, 
                                            void * pDelFunct,
-										   void * pSizeFunct)
+                                           void * pSizeFunct)
 {
     ArrayBean* pAb = new ArrayBean();
 
@@ -645,12 +606,10 @@
     else
     {
         SoapHeader * pSoapHeader = new SoapHeader();
-
         setSoapHeader( pSoapHeader);
     }
 
     m_pSoapEnvelope->m_pSoapHeader->addHeaderBlock( pHeaderBlock);
-
     intStatus = AXIS_SUCCESS;
 
     return intStatus;
@@ -665,7 +624,6 @@
 int SoapSerializer::removeSoapHeader()
 {
     delete m_pSoapEnvelope->m_pSoapHeader;
-
     m_pSoapEnvelope->m_pSoapHeader= NULL;
 
     return AXIS_SUCCESS;  // Can it only be successful?
@@ -677,15 +635,15 @@
  */
 int SoapSerializer::serializeCmplxArray( const Axis_Array * pArray, 
                                          void * pSZFunct,
-										 void * pDelFunct,
+                                         void * pDelFunct,
                                          void * pSizeFunct, 
                                          const AxisChar * pName, 
                                          const AxisChar * pNamespace)
 {
     ArrayBean * pAb = (ArrayBean*) makeArrayBean( pArray->m_Array, 
-											      pSZFunct,
-												  pDelFunct,
-												  pSizeFunct);
+                                                  pSZFunct,
+                                                  pDelFunct,
+                                                  pSizeFunct);
 
     pAb->SetDimension( pArray->m_Size);
 
@@ -707,7 +665,7 @@
     pParam->m_Value.pArray = pAb;
     pParam->m_Type = XSD_ARRAY;
 
-	if( pNamespace != NULL)
+    if( pNamespace != NULL)
     {
         bool blnIsNewNamespacePrefix = false;
         const AxisChar* np = getNamespacePrefix( pNamespace, blnIsNewNamespacePrefix);
@@ -716,24 +674,19 @@
         pParam->setPrefix( np);
 
         if( blnIsNewNamespacePrefix)
-        {
             removeNamespacePrefix( pNamespace);
-        }
 
         setNamespace( pNamespace);
         pParam->serialize( *this);
         setNamespace( originalNamespace); // Revert back original namespace
     }
     else
-    {
         pParam->serialize( *this);
-    }
 
     /* Remove pointer to the array from the ArrayBean to avoid deleting the 
      * array when ArrayBean is deleted. Array will be deleted when the complex
      * type that contains this array is deleted */
     pAb->RemoveArrayPointer();
-
     delete pParam;
 
     return AXIS_SUCCESS;  // Can it only be successful?
@@ -745,9 +698,9 @@
  */
 int SoapSerializer::serializeBasicArray( const Axis_Array * pArray, 
                                          XSDTYPE nType,
-										 const AxisChar * pName)
+                                         const AxisChar * pName)
 {
-	return serializeBasicArray( pArray, NULL, nType, pName);
+    return serializeBasicArray( pArray, NULL, nType, pName);
 }
 
 /*
@@ -756,10 +709,10 @@
  * wrapper method of the complex type.
  */
 int SoapSerializer::serializeBasicArray(const Axis_Array* pArray, 
-										const AxisChar* pNamespace, 
+                                        const AxisChar* pNamespace, 
                                         XSDTYPE nType, const AxisChar* pName)
 {
-	ArrayBean * pAb = (ArrayBean *) makeArrayBean( nType, pArray->m_Array);
+    ArrayBean * pAb = (ArrayBean *) makeArrayBean( nType, pArray->m_Array);
 
     pAb->SetDimension( pArray->m_Size);
 
@@ -788,27 +741,20 @@
         pParam->setPrefix( np);
 
         if( blnIsNewNamespacePrefix)
-        {
             removeNamespacePrefix( pNamespace);
-        }
 
         setNamespace( pNamespace);
-
         pParam->serialize( *this);
-
         setNamespace( originalNamespace); // Revert back original namespace
     }
     else
-    {
         pParam->serialize( *this);
-    }
 
     /* Remove pointer to the array from the ArrayBean to avoid deleting the
      * array when ArrayBean is deleted. Array will be deleted when the complex
      * type that contains this array is deleted
      */
     pAb->RemoveArrayPointer();
-
     delete pParam;
 
     return AXIS_SUCCESS;  // Can it only be successful?
@@ -827,7 +773,7 @@
  * Basic output parameter going to be serialized as an Element later
  */
 int SoapSerializer::addOutputParam( const AxisChar * pchName,
-								    void * pValue, 
+                                    void * pValue, 
                                     XSDTYPE type)
 {
     IAnySimpleType* xsdValue = AxisUtils::createSimpleTypeObject(pValue, type);
@@ -835,9 +781,7 @@
     Param * pParam = new Param();
 
     if( !pParam)
-	{
-		return AXIS_FAIL;
-	}
+        return AXIS_FAIL;
 
     pParam->m_Type = type;
     pParam->m_sName = pchName;
@@ -846,15 +790,12 @@
     pParam->setValue(type, xsdValue);
     
     if( m_pSoapEnvelope &&
-		(m_pSoapEnvelope->m_pSoapBody) &&
-		(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
-    {
+        (m_pSoapEnvelope->m_pSoapBody) &&
+        (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
         m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addOutputParam( pParam);
-    }
     else
     {
         delete pParam;
-
         return AXIS_FAIL;
     }
 
@@ -876,50 +817,44 @@
     IAnySimpleType* pSimpleType = AxisUtils::createSimpleTypeObject(pValue, type);
     int ret;
     ret = serializeAsElement(pName, pNamespace, pSimpleType);
-    // Samisa: got to clean memory allocated in AxisUtils::createSimpleTypeObject
+    // got to clean memory allocated in AxisUtils::createSimpleTypeObject
     delete pSimpleType;
 
     return ret;
 }
 int SoapSerializer::serializeAsElement( const AxisChar * pName,
-									    IAnySimpleType * pSimpleType)
+                                        IAnySimpleType * pSimpleType)
 {
-	return serializeAsElement( pName, NULL, pSimpleType);
+    return serializeAsElement( pName, NULL, pSimpleType);
 }
 
 int SoapSerializer::serializeAsElement( const AxisChar * pName, 
-									    const AxisChar * pNamespace,
-									    IAnySimpleType * pSimpleType) 
+                                        const AxisChar * pNamespace,
+                                        IAnySimpleType * pSimpleType) 
 {
     const AxisChar* pPrefix = NULL;
     bool blnIsNewPrefix = false;
 
     if( pNamespace)
-	{
         pPrefix = getNamespacePrefix( pNamespace, blnIsNewPrefix);
-    }
     
     const AxisChar * pSerialized = NULL;
 
     if( blnIsNewPrefix)
     {
         pSerialized = m_BTSZ.serializeAsElement( pName, pPrefix, pNamespace, pSimpleType);
-        
-		removeNamespacePrefix( pNamespace);
+        removeNamespacePrefix( pNamespace);
     }
     else
-    {
         pSerialized = m_BTSZ.serializeAsElement( pName, pPrefix, pSimpleType);
-    }
 
     if( pSerialized)
     {
         *this << pSerialized;
-
         return AXIS_SUCCESS;  // Can it only be successful?
     }
 
-	return AXIS_FAIL;  // Can it only be unsuccessful?
+    return AXIS_FAIL;  // Can it only be unsuccessful?
 } 
 
 int SoapSerializer::serializeAsAttribute( const AxisChar * pName,
@@ -942,20 +877,17 @@
     const AxisChar * pPrefix = NULL;
 
     if( pNamespace)
-    {
         pPrefix = getNamespacePrefix( pNamespace);
-    }
 
     const AxisChar * pSerialized = m_BTSZ.serializeAsAttribute(pName, pPrefix, pSimpleType);
 
     if( pSerialized)
     {
         *this << pSerialized;
-
         return AXIS_SUCCESS;   // Can it only be successful?
     }
 
-	return AXIS_FAIL;  // Can it only be unsuccessful?
+    return AXIS_FAIL;  // Can it only be unsuccessful?
 }
 
 void SoapSerializer::serializeVargs( int count, const char ** args)
@@ -973,22 +905,19 @@
 
     va_start( vList, pFirst );     /* Initialize variable arguments. */
     
-	const char * pArg;
+    const char * pArg;
     
-	if( pFirst)
-	{
-		*this << pFirst;
-	}
+    if( pFirst)
+        *this << pFirst;
 
     do
     {
         pArg = va_arg( vList, const char*);
 
         if( pArg)
-		{
             *this << pArg;
-		}
-    } while( pArg != NULL);
+    } 
+    while( pArg != NULL);
 
     va_end( vList);              /* Reset variable arguments.      */
 }
@@ -1001,14 +930,10 @@
     if( m_pSoapEnvelope)
     {
         if( !m_pSoapEnvelope->m_pSoapHeader)
-		{
-			m_pSoapEnvelope->m_pSoapHeader = new SoapHeader();
-		}
+            m_pSoapEnvelope->m_pSoapHeader = new SoapHeader();
     }
     else /* error : by this time there should be an envelope */
-    {
         return AXIS_FAIL;
-    }
 
     m_pSoapEnvelope->m_pSoapHeader->addHeaderBlock( (HeaderBlock *) pBlk);
 
@@ -1043,22 +968,20 @@
     if( pPrefix)
     {
         serialize( "<",
-				   pName,
-				   " xsi:type=\"",
-				   pPrefix,
-				   ":",
-				   pName,
-				   "\" xmlns:",
-				   pPrefix,
-				   "=\"",
-				   pNamespace,
-				   "\">",
-				   NULL);
+                   pName,
+                   " xsi:type=\"",
+                   pPrefix,
+                   ":",
+                   pName,
+                   "\" xmlns:",
+                   pPrefix,
+                   "=\"",
+                   pNamespace,
+                   "\">",
+                   NULL);
     }
     else
-    {
         serialize( "<", pName, ">", NULL);
-    }
 }
 
 void SoapSerializer::serializeEndElementOfType( const AxisChar * pName)
@@ -1078,36 +1001,34 @@
 
 SoapMethod * SoapSerializer::getSOAPMethod()
 {
-	/*
-	 *TODO
-	 * return the SOAPMethod object if one is available. If not available create a SOAPMethod
and set it and return it.
-	 */
+    /*
+     *TODO
+     * return the SOAPMethod object if one is available. If not available create a SOAPMethod
and set it and return it.
+     */
 
-	return NULL;
+    return NULL;
 }
 
 int SoapSerializer::setSOAPMethodAttribute( Attribute * pAttribute)
 {
-	if( m_pSoapEnvelope &&
-		(m_pSoapEnvelope->m_pSoapBody) &&
-		(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
+    if( m_pSoapEnvelope &&
+        (m_pSoapEnvelope->m_pSoapBody) &&
+        (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
     {
-		m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addAttribute( pAttribute);
+        m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addAttribute( pAttribute);
 
-		return AXIS_SUCCESS;  // Can it only be successful?
-	}
+        return AXIS_SUCCESS;  // Can it only be successful?
+    }
 
-	return AXIS_FAIL;
+    return AXIS_FAIL;
 }
 
 int SoapSerializer::serializeAnyObject( AnyType * pAnyObject)
 {
     for( int i = 0; i < pAnyObject->_size; i++)
-    {
         serialize( pAnyObject->_array[i], 0);
-    }
 
-	return AXIS_SUCCESS;  // Can it only be successful?
+    return AXIS_SUCCESS;  // Can it only be successful?
 }
 
 int SoapSerializer::addOutputAnyObject( AnyType * pAnyObject)
@@ -1118,11 +1039,9 @@
     pParam->m_Value.pAnyObject = pAnyObject;
 
     if( m_pSoapEnvelope &&
-		(m_pSoapEnvelope->m_pSoapBody) &&
-		(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
-    {
+        (m_pSoapEnvelope->m_pSoapBody) &&
+        (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
         m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addOutputParam( pParam);
-    }
 
     return AXIS_SUCCESS;  // Can it only be successful?
 }
@@ -1134,32 +1053,29 @@
 {
     if ((!m_pSoapEnvelope) || (!m_pSoapEnvelope->m_pSoapHeader)) return NULL;
 
-    return (HeaderBlock*)m_pSoapEnvelope->m_pSoapHeader->getHeaderBlock(false);	
+    return (HeaderBlock*)m_pSoapEnvelope->m_pSoapHeader->getHeaderBlock(false);   

 }
 */
 
 IHeaderBlock * SoapSerializer::getHeaderBlock( const AxisChar * pcName, 
-											   const AxisChar * pcNamespace)
+                                               const AxisChar * pcNamespace)
 {
+    // there has been no <Header> element so there can be no Header blocks	
     if( (!m_pSoapEnvelope) ||
-		(!m_pSoapEnvelope->m_pSoapHeader))
-	{
-		return NULL; 
-	}
-
-	// there has been no <Header> element so there can be no Header blocks
+        (!m_pSoapEnvelope->m_pSoapHeader))
+        return NULL; 
 
     return m_pSoapEnvelope->m_pSoapHeader->getHeaderBlock( pcName, pcNamespace, false);
 }
 
 IHeaderBlock * SoapSerializer::getFirstHeaderBlock()
 {
-	return m_pSoapEnvelope->m_pSoapHeader->getFirstHeaderBlock();
+    return m_pSoapEnvelope->m_pSoapHeader->getFirstHeaderBlock();
 }
 
 IHeaderBlock * SoapSerializer::getNextHeaderBlock()
 {
-	return m_pSoapEnvelope->m_pSoapHeader->getNextHeaderBlock();
+    return m_pSoapEnvelope->m_pSoapHeader->getNextHeaderBlock();
 }
 
 int SoapSerializer::serializeAsChardata( void * pValue, XSDTYPE type)
@@ -1176,24 +1092,24 @@
 
 void SoapSerializer::serializeAttachments( SoapSerializer &pSZ)
 {
-	/*serializing the attachments*/
-	map<AxisXMLString, ISoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
-	while( itCurrAttach != m_SoapAttachments.end())
-    {
-		SoapAttachment *att = ((SoapAttachment *) ((*itCurrAttach).second));
-		if (NULL != att->getBody())
-		{
-			serialize( "\r\n--" MIMEBOUNDARY, NULL);
-			att->serialize(pSZ);
-		}
+    /*serializing the attachments*/
+    map<AxisXMLString, ISoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
+    while( itCurrAttach != m_SoapAttachments.end())
+    {
+        SoapAttachment *att = ((SoapAttachment *) ((*itCurrAttach).second));
+        if (NULL != att->getBody())
+        {
+            serialize( "\r\n--" MIMEBOUNDARY, NULL);
+            att->serialize(pSZ);
+        }
         itCurrAttach++;
     }
-	pSZ.serialize("\r\n--" MIMEBOUNDARY "--\r\n", NULL);
+    pSZ.serialize("\r\n--" MIMEBOUNDARY "--\r\n", NULL);
 }
 
 void SoapSerializer::addAttachment( const AxisChar * achId, ISoapAttachment * pAttach)
 {
-	m_SoapAttachments[achId] = pAttach;
+    m_SoapAttachments[achId] = pAttach;
 }
 
 void SoapSerializer::addAttachments(ISoapAttachment** pAttach, int iAttchArraySize)
@@ -1202,185 +1118,164 @@
     {
          const char *id = ((ISoapAttachment*)pAttach[i])->getAttachmentId();
          m_SoapAttachments[id] = pAttach[i];
-      
     }
  
 }
 
 void SoapSerializer::addAttachmentHeader(const AxisChar * achId,
-										 const AxisChar * achHeaderName,
-										 const AxisChar * achHeaderValue)
+                                         const AxisChar * achHeaderName,
+                                         const AxisChar * achHeaderValue)
 {
 
-	if (m_SoapAttachments[achId] == NULL)
-	{
-		m_SoapAttachments[achId] = new SoapAttachment(m_pContentIdSet);		
-	}
+    if (m_SoapAttachments[achId] == NULL)
+        m_SoapAttachments[achId] = new SoapAttachment(m_pContentIdSet);        
 
-	m_SoapAttachments[achId]->addHeader( achHeaderName, achHeaderValue);
+    m_SoapAttachments[achId]->addHeader( achHeaderName, achHeaderValue);
 }
 
 void SoapSerializer::addAttachmentBody( const AxisChar * achId,
-									    xsd__base64Binary * pAttchBody)
+                                        xsd__base64Binary * pAttchBody)
 {
-	if( m_SoapAttachments[achId] == NULL)
-	{
-		m_SoapAttachments[achId] = new SoapAttachment(m_pContentIdSet);		
-	}
+    if( m_SoapAttachments[achId] == NULL)
+        m_SoapAttachments[achId] = new SoapAttachment(m_pContentIdSet);        
 
-	m_SoapAttachments[achId]->addBody( pAttchBody);
+    m_SoapAttachments[achId]->addBody( pAttchBody);
 }
 
 void SoapSerializer::addNamespaceToEnvelope( AxisChar * pachNamespaceURI,
-											 AxisChar * pachPrefix)
+                                             AxisChar * pachPrefix)
 {
         std::list<Attribute*> attributeList;
-	Attribute * pNameSpace = new Attribute( attributeList,
-											pachPrefix,
-											"xmlns",
-											pachNamespaceURI);
+    Attribute * pNameSpace = new Attribute( attributeList,
+                                            pachPrefix,
+                                            "xmlns",
+                                            pachNamespaceURI);
 
-	m_pSoapEnvelope->addNamespaceDecl( pNameSpace);
+    m_pSoapEnvelope->addNamespaceDecl( pNameSpace);
 
-	addNamespaceToNamespaceList( pachNamespaceURI, pachPrefix);
+    addNamespaceToNamespaceList( pachNamespaceURI, pachPrefix);
 }
 
 void SoapSerializer::addNamespaceToNamespaceList( const AxisChar * pachNamespaceURI,
-												  const AxisChar * pachPrefix)
+                                                  const AxisChar * pachPrefix)
 {
-	m_NsStack[pachNamespaceURI] = pachPrefix;
+    m_NsStack[pachNamespaceURI] = pachPrefix;
 }
 
 ISoapAttachment* SoapSerializer::createSoapAttachment()
 {
-	return new SoapAttachment(m_pContentIdSet);
+    return new SoapAttachment(m_pContentIdSet);
 }
 
 void SoapSerializer::setContentIdSet(ContentIdSet *pContentIdSet) 
 {
-	m_pContentIdSet = pContentIdSet;
+    m_pContentIdSet = pContentIdSet;
 }
 
 bool SoapSerializer::checkAttachmentAvailability()
 {
-	map<AxisXMLString, ISoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
+    map<AxisXMLString, ISoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
 
-	if( itCurrAttach != m_SoapAttachments.end())
-	{
-		return true;
-	}
+    if( itCurrAttach != m_SoapAttachments.end())
+        return true;
 
-	return false;
+    return false;
 }
 
 void SoapSerializer::addAttachmentParameter(ISoapAttachment* att, const char* pName, IAttribute
**attributes, int nAttributes)
 {
-	if (NULL==att)
-		att = static_cast<ISoapAttachment*>(new SoapAttachment(m_pContentIdSet));
-	SoapAttachmentReference *ref = new SoapAttachmentReference(static_cast<SoapAttachment*>(att));
-	m_attachmentRefs.push_back(ref);
+    if (NULL==att)
+        att = static_cast<ISoapAttachment*>(new SoapAttachment(m_pContentIdSet));
+    SoapAttachmentReference *ref = new SoapAttachmentReference(static_cast<SoapAttachment*>(att));
+    m_attachmentRefs.push_back(ref);
 
     Param *pParam = new Param();
     pParam->m_Value.pAttachmentRef = ref;
-	pParam->m_Type = ATTACHMENT;
+    pParam->m_Type = ATTACHMENT;
 
-	if (NULL!=attributes && nAttributes>0) 
-		ref->addAttributes(attributes,nAttributes);
-	
-	if (m_pSoapEnvelope &&
-		(m_pSoapEnvelope->m_pSoapBody) &&
-		(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
-	{
-		m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addOutputParam(pParam);
-	}
-	pParam->setName(pName);
-	m_SoapAttachments[att->getAttachmentId()] = att;
+    if (NULL!=attributes && nAttributes>0) 
+        ref->addAttributes(attributes,nAttributes);
+    
+    if (m_pSoapEnvelope &&
+        (m_pSoapEnvelope->m_pSoapBody) &&
+        (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod)) 
+        m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addOutputParam(pParam);
+        
+    pParam->setName(pName);
+    m_SoapAttachments[att->getAttachmentId()] = att;
 }
 
 IHeaderBlock * SoapSerializer::getCurrentHeaderBlock()
 {
-	return m_pSoapEnvelope->m_pSoapHeader->getCurrentHeaderBlock();
+    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++;
-		}
-	}
-
-	if (NULL==m_pSoapEnvelope->m_pSoapHeader) return "";
-
-// 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 "";
-	}
+    // 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++;
+    }
+
+    if (NULL==m_pSoapEnvelope->m_pSoapHeader) return "";
+
+    // 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);
 
-	return pszValue;
+            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 "";
+
+    return pszValue;
 }
 
 
 int SoapSerializer::deleteHeaderBlock( const AxisChar * pName, 
-									   const AxisChar * pNamespace)
+                                       const AxisChar * pNamespace)
 {
    
     int iStatus = AXIS_SUCCESS;
@@ -1391,9 +1286,7 @@
     if( iStatus == AXIS_NO_REMAINING_SOAP_HEADERS)     
     {
         delete m_pSoapEnvelope->m_pSoapHeader;
-
         m_pSoapEnvelope->m_pSoapHeader = NULL;
-
         iStatus = AXIS_SUCCESS;
     }
 
@@ -1405,14 +1298,10 @@
     m_nCounter = 0; // reset namespace prifix counter 
 
     if( m_pSoapEnvelope && (m_pSoapEnvelope->m_pSoapBody) && (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
-    {
         m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->clearOutParams();    
-    }
 
     if( m_pSoapEnvelope && m_pSoapEnvelope->m_pSoapHeader )
-    {
         m_pSoapEnvelope->m_pSoapHeader->clear();
-    }
 }
 
 AXIS_CPP_NAMESPACE_END



Mime
View raw message