TestClient.cpp

Go to the documentation of this file.
00001 
00026 
00028 #ifdef _MSC_VER 
00029 // Microsoft only extension to the compiler
00030 // Turns off noise about debug symbols being "too long".
00031     #pragma warning( disable : 4786 )
00032 #endif // _MSC_VER 
00033 
00034 #include "TestClient.h"
00035 #include "SOAPEncoder.h"
00036 #include <iostream>
00037 #include <fstream>
00038 
00039 #include "SOAPMethod.h"
00040 #include "SOAPonHTTP.h"    
00041 #include "SOAPParser.h"
00042 #include "SOAPElement.h"
00043 
00044 
00045 extern char *ServerObject;
00046 const bool g_KbDebugging = true;
00048 // Construction/Destruction
00050 struct TestSOAPClient::SOAPMethodTable
00051 {
00053         // Genric 
00054     class CGenric : public SOAPMethod  
00055     {
00056     public:
00057         CGenric():   m_nPort(0){}
00058 
00059         virtual ~CGenric(){}
00060         virtual std::string methodName(){ return std::string( theName ); }
00061 
00062         virtual bool encode( SOAPEncoder& soapEncoder ){
00063                         soapEncoder.encodeArgument( *theRPC );
00064                         return true;  
00065                 }
00066 
00067                 bool isGeneric() { return true; };
00068 
00069                 std::string methodNameAttributes()
00070                 {
00071                         return std::string("");
00072                 }
00073 
00074                 std::string Generic( const std::string &rpc )
00075         {
00076                         theRPC = &rpc;
00077                         theName.clear();
00078                         // first isolate the method name
00079                         for ( unsigned int i = 1; i < rpc.size(); i++ )
00080                                 if ( isspace(rpc[i]) || ( rpc[i] == '>' ) )
00081                                         break;
00082                                 else
00083                                         theName += rpc[i];
00084 
00085             SOAPonHTTP soapOnHTTP;
00086             soapOnHTTP.setHostAndPort( m_szEndpoint, m_nPort );
00087             return soapOnHTTP.send( ServerObject, *this );
00088         }
00089         
00090         std::string m_szEndpoint, theName;
00091                 const std::string *theRPC;
00092         long m_nPort;
00093                 bool LogError, LogDiscovery, LogVolume;
00094 
00095     } m_GenericSOAP;
00096 
00097     std::string m_szEndPointIP;
00098     long m_nPort;
00099 
00100 };
00101 
00102 TestSOAPClient::TestSOAPClient() :
00103     m_pMethodTable( new SOAPMethodTable )
00104 {
00105 }
00106 
00107 TestSOAPClient::~TestSOAPClient()
00108 {
00109     
00110 }
00111 
00112 std::string  TestSOAPClient::Generic( std::string rpc )
00113 {
00114     m_pMethodTable->m_GenericSOAP.m_szEndpoint = m_pMethodTable->m_szEndPointIP;
00115     m_pMethodTable->m_GenericSOAP.m_nPort = m_pMethodTable->m_nPort;
00116 
00117         return  m_pMethodTable->m_GenericSOAP.Generic(rpc);
00118 }
00119 
00120 void TestSOAPClient::setEndPoint( const std::string& szEndPoint, long nPort )
00121 {
00122     m_pMethodTable->m_szEndPointIP = szEndPoint;
00123     m_pMethodTable->m_nPort = nPort;
00124 }

Generated on Tue Mar 28 09:10:15 2006 for Simple SOAP by  doxygen 1.4.6