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 su...@apache.org on 2003/07/18 15:31:45 UTC

cvs commit: xml-axis/c/src/wcg WSClass.h WSClass.cpp WCGenerator.cpp

susantha    2003/07/18 06:31:45

  Modified:    c/src/wcg WSClass.h WSClass.cpp WCGenerator.cpp
  Log:
  added more functionality
  
  Revision  Changes    Path
  1.3       +1 -0      xml-axis/c/src/wcg/WSClass.h
  
  Index: WSClass.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/WSClass.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSClass.h	1 Jul 2003 10:50:11 -0000	1.2
  +++ WSClass.h	18 Jul 2003 13:31:44 -0000	1.3
  @@ -92,6 +92,7 @@
   	WSClass();
   	virtual ~WSClass();
   private:
  +	string m_AWSName;
   	string m_Name;
   	list<Variable*> m_Variables;
   	list<Method*> m_Constructors;
  
  
  
  1.3       +95 -5     xml-axis/c/src/wcg/WSClass.cpp
  
  Index: WSClass.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/WSClass.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSClass.cpp	1 Jul 2003 10:50:11 -0000	1.2
  +++ WSClass.cpp	18 Jul 2003 13:31:44 -0000	1.3
  @@ -63,6 +63,7 @@
   // WSClass.cpp: implementation of the WSClass class.
   //
   //////////////////////////////////////////////////////////////////////
  +#pragma warning (disable : 4786)
   
   #include "WSClass.h"
   
  @@ -97,7 +98,8 @@
   
   void WSClass::SetClassName(string &sName)
   {
  -	m_Name = sName;
  +	m_AWSName = sName;
  +	m_Name = sName + "Wrapper";
   }
   
   void WSClass::AddVariable(Variable *pVar)
  @@ -129,8 +131,26 @@
   {
   	try {
   		//add wrapper class
  -		file << "class " << GetName() << "Wrapper" << " : public WrapperClassHandler" << endl << "{" << endl;
  -		
  +		file << "class " << m_Name << " : public WrapperClassHandler" << endl << "{" << endl;
  +		file << "public:" << endl;
  +		//default constructor
  +		file << "\t" << m_Name << "();" << endl; 
  +		//destructor
  +		file << "\tvirtual ~" << m_Name << "();" << endl; 
  +		file << "public:" << "//implementation of WrapperClassHandler interface" << endl;	
  +		file << "\tint Invoke(IMessageData* mc);" << endl; 		
  +		file << "\tvoid OnFault(IMessageData* pMsg);" << endl; 		
  +		file << "\tint Init();" << endl; 		
  +		file << "\tint Fini();" << endl; 	
  +		file << "private:" << "//Methods corresponding to the web service methods" << endl;
  +		file << "\tint SetResponseMethod(IMessageData* mc, const char* name);" << endl; 			
  +		//wrapper methods for each webservice method
  +		for (list<Method*>::iterator it = m_Methods.begin(); it != m_Methods.end(); it++)
  +		{
  +			(*it)->GenerateMethodDef(file);
  +		}
  +		file << "private:" << "// Actual web service object" << endl;
  +		file << "\t" << m_AWSName << " *pWs;" << endl; 
   		file << "};" << endl;	
   	}
   	catch(...) //any exception
  @@ -142,5 +162,75 @@
   
   int WSClass::GenerateClassImpl(File &file)
   {
  -	return 0;
  -}
  +	try {
  +		//default constructor
  +		file << m_Name << "::" << m_Name << "()" << endl;
  +		file << "{" << endl;
  +		file << "\tpWs = new " << m_AWSName << "();" << endl;
  +		file << "}" << endl;
  +		file << endl;
  +		//destructor
  +		file << m_Name << "::~" << m_Name << "()" << endl;
  +		file << "{" << endl;
  +		file << "\tdelete pWs;" << endl; 
  +		file << "}" << endl;
  +		file << endl;
  +
  +		//implementation of WrapperClassHandler interface
  +		file << "// Implementation of WrapperClassHandler interfaces." << endl;
  +		file << "int " << m_Name << "::Invoke(IMessageData* mc)" << endl; 		
  +		file << "{" << endl;
  +		file << "\tstring method = mc->getSoapDeserializer()->GetMethodName();" << endl;
  +		bool tab = true;
  +		list<Method*>::iterator it;
  +		for (it = m_Methods.begin(); it != m_Methods.end(); it++)
  +		{
  +			if (tab) { file << "\t"; tab = false;} 
  +			file << "if (method == \"" << (*it)->GetName() << "\")" << endl;
  +			file << "\t\treturn " << (*it)->GetName() << "(mc);" << endl;
  +			file << "\telse ";
  +		}
  +		file << "return FAIL;" << endl;
  +		file << "}" << endl;
  +		file << endl;
  +
  +		file << "void" << m_Name << "::OnFault(IMessageData* pMsg)" << endl; 		
  +		file << "{" << endl;
  +		file << "}" << endl;
  +		file << endl;
  +
  +		file << "int " << m_Name << "::Init()" << endl; 		
  +		file << "{" << endl;
  +		file << "\treturn 0;" << endl; 
  +		file << "}" << endl;
  +		file << endl;
  +
  +		file << "int " << m_Name << "::Fini()" << endl; 	
  +		file << "{" << endl;
  +		file << "\treturn 0;" << endl; 
  +		file << "}" << endl;
  +		file << endl;
  +
  +		file << "int " << m_Name << "::SetResponseMethod(IMessageData* mc, const char* name)" << endl; 			
  +		file << "{" << endl;
  +		file << "\tstring method = name;" << endl;
  +		file << "\tISoapMethod* pMethod = mc->getSoapSerializer()->createSoapMethod();" << endl;
  +		file << "\tpMethod->setLocalName(method + \"Response\");" << endl;
  +		file << "\tpMethod->setPrefix(\"" << "amp" << "\");"<< endl; //amp - axis method prefix :)
  +		file << "\tpMethod->setUri(\"" << g_ClassNamespaces[m_AWSName] << "\");"<< endl; //http://www.opensource.lk will come from wsdd
  +		file << "\treturn SUCCESS;" << endl; 
  +		file << "}" << endl;
  +		file << endl;
  +
  +		//wrapper methods for each webservice method
  +		for (it = m_Methods.begin(); it != m_Methods.end(); it++)
  +		{
  +			(*it)->GenerateMethodImpl(m_Name, file);
  +		}
  +	}
  +	catch(...) //any exception
  +	{
  +		return 1;
  +	}
  +	return 0; //success}
  +}
  \ No newline at end of file
  
  
  
  1.2       +4 -2      xml-axis/c/src/wcg/WCGenerator.cpp
  
  Index: WCGenerator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/WCGenerator.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WCGenerator.cpp	1 Jul 2003 10:50:11 -0000	1.1
  +++ WCGenerator.cpp	18 Jul 2003 13:31:44 -0000	1.2
  @@ -1,6 +1,7 @@
   // WCGenerator.cpp: implementation of the WCGenerator class.
   //
   //////////////////////////////////////////////////////////////////////
  +#pragma warning (disable : 4786)
   
   #include "WCGenerator.h"
   
  @@ -8,7 +9,7 @@
   // Construction/Destruction
   //////////////////////////////////////////////////////////////////////
   #include "WSClass.h"
  -#include "HeaderFile.h"
  +#include "TranslationUnit.h"
   
   WCGenerator::WCGenerator()
   {
  @@ -39,7 +40,7 @@
   {
   	return 0;
   }
  -
  +/*
   int main(int argc, char*argv[])
   {
   	WSClass* pCl = new WSClass();
  @@ -49,3 +50,4 @@
   	hf.GenerateWrapperClassDef();
   	return 0;
   }
  +*/
  \ No newline at end of file