bool WizXmlRpcResultFromXml(CWizXMLDocument& doc, CWizXmlRpcValue** ppRet) { CWizXMLNode nodeMethodResponse; doc.FindChildNode("methodResponse", nodeMethodResponse); if (nodeMethodResponse.isNull()) { TOLOG("Failed to get methodResponse node!"); return false; } CWizXMLNode nodeTest; if (!nodeMethodResponse.GetFirstChildNode(nodeTest)) { TOLOG("Failed to get methodResponse child node!"); return false; } CString strTestName = nodeTest.GetName(); if (0 == strTestName.CompareNoCase("params")) { CWizXMLNode nodeParamValue; nodeTest.FindNodeByPath("param/value", nodeParamValue); if (nodeParamValue.isNull()) { TOLOG("Failed to get param value node of params!"); return false; } return WizXmlRpcValueFromXml(nodeParamValue, ppRet); } else if (0 == strTestName.CompareNoCase("fault")) { CWizXMLNode nodeFaultValue; nodeTest.FindChildNode(_T("value"), nodeFaultValue); if (nodeFaultValue.isNull()) { TOLOG("Failed to get fault value node!"); return false; } CWizXmlRpcFaultValue* pFault = new CWizXmlRpcFaultValue(); pFault->Read(nodeFaultValue); *ppRet = pFault; return true; } else { TOLOG1("Unknown response node name: %1", strTestName); return false; } }
BOOL WizXmlRpcValueFromXml(CWizXMLNode& nodeValue, CWizXmlRpcValue** ppRet) { *ppRet = NULL; // CWizXMLNode nodeTypeTest; nodeValue.GetFirstChildNode(nodeTypeTest); if (nodeTypeTest.isNull()) { CString strText = nodeValue.GetText(); // *ppRet = new CWizXmlRpcStringValue(strText); return TRUE; } // CWizXmlRpcValue* pValue = NULL; // CString strValueType = nodeTypeTest.GetName(); // if (0 == strValueType.CompareNoCase(_T("int")) || 0 == strValueType.CompareNoCase(_T("i4"))) { pValue = new CWizXmlRpcIntValue(); } else if (0 == strValueType.CompareNoCase(_T("string")) || 0 == strValueType.CompareNoCase(_T("ex:nil")) || 0 == strValueType.CompareNoCase(_T("ex:i8"))) { pValue = new CWizXmlRpcStringValue(); } else if (0 == strValueType.CompareNoCase(_T("nil")) || 0 == strValueType.CompareNoCase(_T("i8"))) { pValue = new CWizXmlRpcStringValue(); } else if (0 == strValueType.CompareNoCase(_T("struct"))) { pValue = new CWizXmlRpcStructValue(); } else if (0 == strValueType.CompareNoCase(_T("array"))) { pValue = new CWizXmlRpcArrayValue(); } else if (0 == strValueType.CompareNoCase(_T("base64"))) { pValue = new CWizXmlRpcBase64Value(); } else if (0 == strValueType.CompareNoCase(_T("boolean")) || 0 == strValueType.CompareNoCase(_T("bool"))) { pValue = new CWizXmlRpcBoolValue(); } else if (0 == strValueType.CompareNoCase(_T("dateTime.iso8601"))) { pValue = new CWizXmlRpcTimeValue(); } else { TOLOG1(_T("Unknown xmlrpc value type:%1"), strValueType); return FALSE; } // // ATLASSERT(pValue); // if (pValue->Read(nodeValue)) { *ppRet = pValue; return TRUE; } // TOLOG(_T("Failed to read xmlrpc value!")); // delete pValue; // return FALSE; }