// XMLRPC.cpp: implementation of the CXMLRPC class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "KBEditors.h" #include "XMLRPC.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CXMLRPC::CXMLRPC(CString Url) { HRESULT hr; pIXMLHttpRequest = NULL; hr = CoCreateInstance(MSXML::CLSID_XMLHTTPRequest, NULL, CLSCTX_INPROC_SERVER, MSXML::IID_IXMLHttpRequest, (void**)&pIXMLHttpRequest); if(!SUCCEEDED(hr)){ ::MessageBox(NULL, _T("XMLRPC Initalization failed !"+Url), _T(""), MB_OK); return; } this->Url = Url; } CXMLRPC::~CXMLRPC() { } CString CXMLRPC::Send(CString str) { HRESULT hr; // Create XMLHttpRequest object and initialize pIXMLHttpRequest. hr = pIXMLHttpRequest->open(_bstr_t(_T("GET")), _bstr_t(_T(Url)), _variant_t(VARIANT_FALSE), _variant_t(""), _variant_t("")); if(!SUCCEEDED(hr)) ::MessageBox(NULL, _T("XMLRPC connection failed !"), _T(""), MB_OK); pIXMLHttpRequest->send(_variant_t(str)); BSTR ss; pIXMLHttpRequest->get_responseText(&ss); CString result = ss; return result; } CString CXMLRPC::Call(CString FunName, ...) { CString arg; CString Params; BOOL first = TRUE; va_list argV; va_start( argV, FunName); /* Initialize variable arguments. */ for(;;) { void * temp = va_arg( argV, void *); if (temp == NULL) break; else { arg = CString((char *)temp); if (first){ Params += "\"" + arg + "\""; first= FALSE; } else Params += ",\"" + arg + "\""; } } va_end( argV); /* Reset variable arguments. */ return Send(""+FunName +"("+ Params + ")"+""); } /*void CXMLRPC :: decode(CString msg, CString cmd, CStringList args) { MSXML ::IXMLDOMDocument * doc; doc = CXmlUtils::CreateDoc(); } */