Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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());
            }
        }