public static void TestReadVersion() { XmlRpcClient client = new XmlRpcClient(); client.Url = Url; client.Path = "common"; XmlRpcResponse response = client.Execute("version"); Console.WriteLine("version"); Console.WriteLine("REQUEST: "); client.WriteRequest(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("RESPONSE: "); client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); if (response.IsFault()) { Console.WriteLine(response.GetFaultString()); } else { Console.WriteLine(response.GetString()); } }
public static void Test(String xmlcommand) { XmlRpcClient client = new XmlRpcClient(); client.Url = Url; //client.Path = "common"; XmlRpcRequest requestCreate = new XmlRpcRequest(xmlcommand); //XmlRpcResponse responseCreate = client.Execute(requestCreate); client.Execute(requestCreate); //xml malformed error client.WriteRequest(Console.Out); Console.ReadKey(); }
public void example() { XmlRpcClient client = new XmlRpcClient(); //client.Url = url; //client.Path = UtilsApiTms.PATH_XML_API; //XmlRpcRequest requestLogin = new XmlRpcRequest(UtilsApiTms.METHOD_AUTHENTICATE); //requestLogin.AddParams(database, userName, password, XmlRpcParameter.EmptyStruct()); //XmlRpcResponse rps = client.Execute(requestLogin); client.WriteRequest(Console.Out); client.WriteResponse(Console.Out); //return !rps.IsFault() ? rps.GetString() : UtilsApiTms.LOGIN_FAILED; //""rps.GetFaultString(); }
public static void TestCreateRecord() { XmlRpcClient client = new XmlRpcClient(); client.Url = Url; client.Path = "common"; // LOGIN XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate"); requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct()); XmlRpcResponse responseLogin = client.Execute(requestLogin); Console.WriteLine("authenticate"); Console.WriteLine("REQUEST: "); client.WriteRequest(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("RESPONSE: "); client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("LOGIN: "******"object"; XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw"); requestCreate.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "create", XmlRpcParameter.AsArray( XmlRpcParameter.AsStruct( XmlRpcParameter.AsMember("name", "Albert Einstein") , XmlRpcParameter.AsMember("image", Convert.ToBase64String(File.ReadAllBytes("img/einstein.jpg"))) , XmlRpcParameter.AsMember("email", "*****@*****.**") ) ) ); XmlRpcResponse responseCreate = client.Execute(requestCreate); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("create"); Console.WriteLine("REQUEST: "); client.WriteRequest(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("RESPONSE: "); client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("READ: "); if (responseCreate.IsFault()) { Console.WriteLine(responseCreate.GetFaultString()); } else { Console.WriteLine(responseCreate.GetString()); } }
public static void TestSearchReadRecords() { XmlRpcClient client = new XmlRpcClient(); client.Url = Url; client.Path = "common"; // LOGIN XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate"); requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct()); XmlRpcResponse responseLogin = client.Execute(requestLogin); // Console.WriteLine("authenticate"); // Console.WriteLine("REQUEST: "); // client.WriteRequest(Console.Out); // Console.WriteLine(); // Console.WriteLine(); // Console.WriteLine("RESPONSE: "); // client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("LOGIN: "******"object"; XmlRpcRequest requestSearch = new XmlRpcRequest("execute_kw"); requestSearch.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "search_read", XmlRpcParameter.AsArray( XmlRpcParameter.AsArray( // XmlRpcParameter.AsArray("is_company", "=", true), XmlRpcRequest.AsArray("customer", "=", true) XmlRpcParameter.AsArray("name", "ilike", "t") ) ), XmlRpcParameter.AsStruct( XmlRpcParameter.AsMember("fields", XmlRpcParameter.AsArray("name", "email")) // ,XmlRpcParameter.AsMember("limit", 2) ) ); XmlRpcResponse responseSearch = client.Execute(requestSearch); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("search"); Console.WriteLine("REQUEST: "); client.WriteRequest(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("RESPONSE: "); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("SEARCH: "); if (responseSearch.IsFault()) { Console.WriteLine(responseSearch.GetFaultString()); } else { Console.WriteLine(responseSearch.GetString()); } }