c#.net 调用xmlrpc 的例子



  • [code]
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using CookComputing.XmlRpc;
    using System.Configuration;

    namespace BPM.WebService
    {
        #region 头部定义
        [WebService(Namespace = "http://BPM/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]

        // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
        [System.Web.Script.Services.ScriptService]
        #endregion
        public class OpenErpRpc_Budget : BPM.WebService.BaseService
        {

            [XmlRpcUrl("http://192.168.168.217:8069/xmlrpc/common")]
            public interface IOpenERPCommon : IXmlRpcProxy
            {

                [XmlRpcMethod("login")]
                int Login(string DB, string USER, string PASS);
            }

            [XmlRpcUrl("http://192.168.168.217:8069/xmlrpc/object")]   
            public interface IOpenERPObject : IXmlRpcProxy
            {
                [XmlRpcMethod("execute")]
                object execute(string dbname, int uid, string pwd, string className, string method, params string[] args);
            }
            string database = ConfigurationSettings.AppSettings["xxys_database"].ToString();
            string user = ConfigurationSettings.AppSettings["xxys_user"].ToString();
            string password = ConfigurationSettings.AppSettings["xxys_password"].ToString();
            int uid = 0;


            public OpenErpRpc_Budget()
            {
                IOpenERPCommon proxy = XmlRpcProxyGen.Create<IOpenERPCommon>();
                uid = proxy.Login(database, user, password);
            }

            [WebMethod(Description = "OPENERP的RPC调用")]
            public object Execute(string className, string Method, params string[] args)
            {
                IOpenERPObject proxy2 = XmlRpcProxyGen.Create<IOpenERPObject>();
                object ret2 = proxy2.execute(database, uid, password, className, Method, args);
                return ret2;
            }




        }
    }


    [/code]



  • [code]
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using CookComputing.XmlRpc;
    using System.Configuration;

    namespace BPM.WebService
    {
        #region 头部定义
        [WebService(Namespace = "http://BPM/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]

        // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
        [System.Web.Script.Services.ScriptService]
        #endregion
        public class OpenErpRpc_Budget : BPM.WebService.BaseService
        {

            [XmlRpcUrl("http://192.168.168.217:8069/xmlrpc/common")]
            public interface IOpenERPCommon : IXmlRpcProxy
            {

                [XmlRpcMethod("login")]
                int Login(string DB, string USER, string PASS);
            }

            [XmlRpcUrl("http://192.168.168.217:8069/xmlrpc/object")]   
            public interface IOpenERPObject : IXmlRpcProxy
            {
                [XmlRpcMethod("execute")]
                object execute(string dbname, int uid, string pwd, string className, string method, params string[] args);
            }
            string database = ConfigurationSettings.AppSettings["xxys_database"].ToString();
            string user = ConfigurationSettings.AppSettings["xxys_user"].ToString();
            string password = ConfigurationSettings.AppSettings["xxys_password"].ToString();
            int uid = 0;


            public OpenErpRpc_Budget()
            {
                IOpenERPCommon proxy = XmlRpcProxyGen.Create<IOpenERPCommon>();
                uid = proxy.Login(database, user, password);
            }

            [WebMethod(Description = "OPENERP的RPC调用")]
            public object Execute(string className, string Method, params string[] args)
            {
                IOpenERPObject proxy2 = XmlRpcProxyGen.Create<IOpenERPObject>();
                object ret2 = proxy2.execute(database, uid, password, className, Method, args);
                return ret2;
            }




        }
    }


    [/code]


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待