roshan      2003/07/14 23:59:34

  Modified:    c/src/soap SoapSerializer.h SoapSerializer.cpp SoapMethod.h
                        SoapMethod.cpp
  Log:
  added code
  
  Revision  Changes    Path
  1.3       +8 -3      xml-axis/c/src/soap/SoapSerializer.h
  
  Index: SoapSerializer.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/soap/SoapSerializer.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SoapSerializer.h  27 Jun 2003 03:30:29 -0000      1.2
  +++ SoapSerializer.h  15 Jul 2003 06:59:34 -0000      1.3
  @@ -73,19 +73,24 @@
   #endif // _MSC_VER > 1000
   
   #include "SoapEnvelope.h"
  +#include "../common/ISoapSerializer.h"
   
  -class SoapSerializer
  +class SoapSerializer : public ISoapSerializer                                       
                   
   {
   private:
        static int iCounter;
        SoapEnvelope* m_pSoapEnvelope;  
        int m_iSoapVersion;
  -
  +     char m_cSerializedBuffer[1024];
  +     int m_iCurrentSerBufferSize;
   public:
  +     ISoapMethod* createSoapMethod();        
  +     int flushSerializedBuffer();
  +     SoapSerializer& operator<<(const char *cSerialized);
        static string getNewNamespacePrefix();
        int setSoapVersion(SOAP_VERSION);
        void init();
  -     int getStream(string&);
  +     int getStream();
        int setSoapFault(SoapFault* pSoapFault);
        int setSoapMethod(SoapMethod* pSoapMethod);
        int setSoapBody(SoapBody* pSoapBody);
  
  
  
  1.4       +52 -4     xml-axis/c/src/soap/SoapSerializer.cpp
  
  Index: SoapSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/soap/SoapSerializer.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SoapSerializer.cpp        30 Jun 2003 06:09:11 -0000      1.3
  +++ SoapSerializer.cpp        15 Jul 2003 06:59:34 -0000      1.4
  @@ -67,6 +67,9 @@
   
   #include "SoapSerializer.h"
   #include "../common/GDefine.h"
  +#include <iostream>
  +
  +extern "C" int sendSoapResponse(char *cSerializedStream);
   
   int SoapSerializer::iCounter=0;
   
  @@ -162,18 +165,21 @@
        return m_sSerializedStream;
   }*/
   
  -int SoapSerializer::getStream(string& sSerialized)
  +int SoapSerializer::getStream()
   {
        int iStatus= SUCCESS;
   
        if(m_pSoapEnvelope) {
  -             iStatus= m_pSoapEnvelope->serialize(sSerialized, 
(SOAP_VERSION)m_iSoapVersion);
  +             iStatus= m_pSoapEnvelope->serialize(*this, 
(SOAP_VERSION)m_iSoapVersion);
  +             //cout<<endl<<"after getStream"<<endl;
  +             //SoapSerializer tmp_sz;
  +             //iStatus= m_pSoapEnvelope->serialize(sSerialized, tmp_sz, 
(SOAP_VERSION)m_iSoapVersion);
                //does this need to be handled here or at the top level. Discuss this.
                //if(iStatus==FAIL) {
                //      sSerialized="";
                //}
        }
  -
  +     flushSerializedBuffer();
        return iStatus;
   }
   
  @@ -189,6 +195,8 @@
        }
   
        iCounter=0;
  +     m_iCurrentSerBufferSize=0;
  +     m_cSerializedBuffer[0]='\0'; //make buffer to empty content (as a char*)
   }
   
   int SoapSerializer::setSoapVersion(SOAP_VERSION eSOAP_VERSION)
  @@ -201,8 +209,48 @@
   {
        iCounter++;
        
  -     char cCounter[64];      
  +     char cCounter[64];
        sprintf(cCounter, "%d", iCounter);
        
        return string("ns")+ cCounter;
   }
  +
  +SoapSerializer& SoapSerializer::operator <<(const char *cSerialized)
  +{
  +     int iTmpSerBufferSize= strlen(cSerialized);
  +     if((m_iCurrentSerBufferSize+iTmpSerBufferSize)>1023) {
  +             flushSerializedBuffer();                
  +     }
  +     cout<<cSerialized;
  +     strcat(m_cSerializedBuffer, cSerialized);
  +     //cout<<m_cSerializedBuffer<<"END@@";
  +
  +     m_iCurrentSerBufferSize+= iTmpSerBufferSize;
  +
  +     return *this;
  +     //call the ruputs to send this soap response
  +     //ruputs(m_cSerializedBuffer);
  +}
  +
  +int SoapSerializer::flushSerializedBuffer()
  +{
  +     //cout<<"++++++++++++++++"<<"flushed"<<endl;
  +     //cout<<"++++++++++++++++"<<m_cSerializedBuffer<<endl;
  +     sendSoapResponse(m_cSerializedBuffer);
  +     m_cSerializedBuffer[0]= '\0';
  +     m_iCurrentSerBufferSize=0;
  +
  +     return SUCCESS;
  +}
  +
  +ISoapMethod* SoapSerializer::createSoapMethod()
  +{
  +     SoapMethod* pMethod = new SoapMethod();
  +     setSoapMethod(pMethod);
  +     return pMethod;
  +}
  +
  +/*SoapMethodBase* SoapSerializer::createSoapMethodInstance()
  +{
  +
  +}*/
  
  
  
  1.4       +11 -9     xml-axis/c/src/soap/SoapMethod.h
  
  Index: SoapMethod.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/soap/SoapMethod.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SoapMethod.h      28 Jun 2003 05:08:15 -0000      1.3
  +++ SoapMethod.h      15 Jul 2003 06:59:34 -0000      1.4
  @@ -73,6 +73,7 @@
   #endif // _MSC_VER > 1000
   
   #include "../common/Param.h"
  +#include "../common/ISoapMethod.h"
   #include <list>
   
   class Attribute;
  @@ -99,14 +100,16 @@
    *   @brief  The SOAP Body of a SOAP Envelope according to SOAP 1.2 specification.
    */
   
  -class SoapMethod  
  +class SoapMethod : public ISoapMethod
   {
   
   private:
  +     int serializeAttributes(SoapSerializer& pSZ);
  +     //int serializeAttributes(string& sSerialized);
        list<Attribute*> m_attributes;
  -     bool isSerializable();
  -     //string serializeOutputParam();
  -     int serializeOutputParam(string&);
  +     bool isSerializable();  
  +     int serializeOutputParam(SoapSerializer& pSZ);
  +     //int serializeOutputParam(string&);
        string m_strPrefix;
        string m_strLocalname;
        string m_strUri;
  @@ -115,12 +118,11 @@
        //string m_strMethodSerialized;
        //test line
   
  -public:      
  -     int serializeAttributes(string& sSerialized);
  +public:                      
        int addAttribute(Attribute* pAttribute);
  -     string& getMethodName();
  -     //string& serialize();
  -     int serialize(string&);
  +     string& getMethodName();        
  +     int serialize(SoapSerializer& pSZ);
  +     //int serialize(string&);
        void setOutputParam(Param &param);
        void addInputParam(Param* param);
        void setUri(const string &uri);
  
  
  
  1.4       +67 -30    xml-axis/c/src/soap/SoapMethod.cpp
  
  Index: SoapMethod.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/soap/SoapMethod.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SoapMethod.cpp    28 Jun 2003 05:08:15 -0000      1.3
  +++ SoapMethod.cpp    15 Jul 2003 06:59:34 -0000      1.4
  @@ -66,6 +66,7 @@
   //////////////////////////////////////////////////////////////////////
   
   #include "SoapMethod.h"
  +#include "SoapSerializer.h"
   #include "Attribute.h"
   #include "../common/GDefine.h"
   
  @@ -120,16 +121,49 @@
    * If not it returns FAIL. The caller of this method has to deal in a 
    * appropriate manner after calling this method.
    */
  -int SoapMethod::serialize(string& sSerialized)
  +int SoapMethod::serialize(SoapSerializer& pSZ)
   {    
  -     /* commented on 10th Jun 2003 at 4.10 pm
  -     sSerialized= sSerialized+ "<"+ m_strPrefix+ ":"+ m_strLocalname+ 
  -                                     " xmlns:"+ m_strPrefix+ "=\""+ m_strUri+ "\">";
  +     int iStatus= SUCCESS;
   
  -     serializeOutputParam(sSerialized);
  +     do {
  +             if(isSerializable()) {
  +                                     
  +                     pSZ << "<" << m_strPrefix.c_str() << ":" << 
m_strLocalname.c_str() << " xmlns:" << m_strPrefix.c_str()
  +                             << "=\"" << m_strUri.c_str() << "\"";
  +
  +                     iStatus= serializeAttributes(pSZ);
  +                     if(iStatus==FAIL) {
  +                             break;
  +                     }
  +                     
  +                     pSZ << ">";
  +
  +                     iStatus= serializeOutputParam(pSZ);
  +                     if(iStatus==FAIL) {
  +                             break;
  +                     }
  +                     
  +                     pSZ << "</";
  +
  +                     if(m_strPrefix.length() != 0) {                                
 
  +                             pSZ<< m_strPrefix.c_str() << ":";
  +                     }
  +                     
  +                     pSZ << m_strLocalname.c_str() << ">";
  +
  +                     iStatus= SUCCESS;
  +             } else {
  +                     iStatus= FAIL;
  +             }
  +     } while(0);
  +                     
  +     return iStatus;
  +}
   
  -     sSerialized= sSerialized+ "</"+ m_strPrefix+ ":"+ m_strLocalname+ ">"+ "\n";   
 
  -     */
  +/*
  +comm on 11/7/2003 9.10am
  +int SoapMethod::serialize(string& sSerialized)
  +{    
        
        int iStatus= SUCCESS;
   
  @@ -177,36 +211,24 @@
                        
        return iStatus;
   }
  +*/
   
  -/*string& SoapMethod::serialize()
  -{
  -     m_strMethodSerialized="";
  +int SoapMethod::serializeOutputParam(SoapSerializer& pSZ)
  +{    
  +     //serialization sould come here
  +     //return m_pOutputParam->serialize(pSZ);
   
  -     m_strMethodSerialized= "<"+ m_strPrefix+ ":"+ m_strLocalname+ 
  -                                     " xmlns:"+ m_strPrefix+ "=\""+ m_strUri+ "\">"+
  -                                     serializeOutputParam()+
  -                                     "</"+ m_strPrefix+ ":"+ m_strLocalname+ ">";   
 
  -                     
  -     return m_strMethodSerialized;
  -}*/
  +     pSZ<<"serialization of output param";
  +     return SUCCESS;
  +}
   
  +/*
  +comm on 11/7/2003 9.10am
   int SoapMethod::serializeOutputParam(string& sSerialized)
   {    
        return m_pOutputParam->serialize(sSerialized);
   }
  -
  -/*string SoapMethod::serializeOutputParam()
  -{
  -     string strOutputParamSer="";
  -     
  -     //add serialization of param here
  -     strOutputParamSer= "serialization of out put param";*/
  -     /*this shout change to
  -      * strOutputParamSer= m_pOutputParam.serialize();
  -      */
  -
  -     /*return strOutputParamSer;
  -}*/
  +*/
   
   string& SoapMethod::getMethodName()
   {
  @@ -238,6 +260,20 @@
        return SUCCESS;
   }
   
  +int SoapMethod::serializeAttributes(SoapSerializer& pSZ)
  +{
  +     list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
  +
  +     while(itCurrAttribute != m_attributes.end()) {          
  +             (*itCurrAttribute)->serialize(pSZ);
  +             itCurrAttribute++;              
  +     }       
  +
  +     return SUCCESS; 
  +}
  +
  +/*
  +comm on 11/7/2003 9.10am
   int SoapMethod::serializeAttributes(string &sSerialized)
   {
        list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
  @@ -249,3 +285,4 @@
   
        return SUCCESS; 
   }
  +*/
  \ No newline at end of file
  
  
  

Reply via email to