成都创新互联网站制作重庆分公司

怎么调用C#的WebService-创新互联

这篇文章主要讲解了“怎么调用C#的WebService”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么调用C#的WebService”吧!

创新互联是专业的代县网站建设公司,代县接单;提供成都网站建设、成都网站设计,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行代县网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

1. 水晶易表不能识别WS接口返回的DataTable或DataSet数据类型,会提示“无法加载URL”

3. C#调用Oracle的Package,并返回数据列表

2. 经查证,可以接受string类型的,如果需要返回数据列表,那么需要借助数组来返回,代码实现如下:


复制代码 代码如下:


public WeekSale_Table GetData(string skc1, string skc2, string week1, string week2, string week3, string week4)
        {
            try
            {
     //C#调用Oracle的包,返回数据列表
                OracleConnection orcn = new OracleConnection(ConfigurationManager.AppSettings["SAPBI"].ToString());
                OracleCommand cmd = new OracleCommand("pkg_cx_Productlifecycle.skcweeksale", orcn);
                cmd.CommandType = CommandType.StoredProcedure;
                OracleParameter ip0 = new OracleParameter("skc1", OracleType.VarChar);
                OracleParameter ip1 = new OracleParameter("skc2", OracleType.VarChar);
                OracleParameter ip2 = new OracleParameter("week1", OracleType.VarChar);
                OracleParameter ip3 = new OracleParameter("week2", OracleType.VarChar);
                OracleParameter ip4 = new OracleParameter("week3", OracleType.VarChar);
                OracleParameter ip5 = new OracleParameter("week4", OracleType.VarChar);

                ip0.Value = skc1;
                ip1.Value = skc2;
                ip2.Value = week1;
                ip3.Value = week2;
                ip4.Value = week3;
                ip5.Value = week4;

                cmd.Parameters.Add(ip0);
                cmd.Parameters.Add(ip1);
                cmd.Parameters.Add(ip2);
                cmd.Parameters.Add(ip3);
                cmd.Parameters.Add(ip4);
                cmd.Parameters.Add(ip5);

                OracleParameter p1 = new OracleParameter("p_rc", OracleType.Cursor);
                p1.Direction = System.Data.ParameterDirection.Output;
                cmd.Parameters.Add(p1);

                OracleDataAdapter command = new OracleDataAdapter(cmd);
                DataSet ds = new DataSet();
                command.Fill(ds, "Table");
                DataTable dt = ds.Tables["Table"];
                WeekSale_Table wt = new WeekSale_Table();
                wt.row = new WeekSale_Row[dt.Rows.Count];
                int rcount = dt.Rows.Count;
                for (int i = 0; i < rcount; i++)
                {
                    DataRow dr = dt.Rows[i];
                    WeekSale_Row row = new WeekSale_Row();
                    row.DISCOUNT1 = dr["DISCOUNT1"].ToString();
                    row.DISCOUNT2 = dr["DISCOUNT2"].ToString();
                    row.FCALCSUMS1 = dr["FCALCSUMS1"].ToString();
                    row.FCALCSUMS2 = dr["FCALCSUMS2"].ToString();
                    row.NUMS1 = dr["NUMS1"].ToString();
                    row.NUMS2 = dr["NUMS2"].ToString();
                    row.SKC1 = dr["SKC1"].ToString();
                    row.SKC2 = dr["SKC2"].ToString();
                    row.WEEK = dr["WEEK"].ToString();
                    row.WEEKS = dr["WEEKS"].ToString();
                    wt.row[i] = row;
                }
                return wt;
            }
            catch
            {
                return null;
            }
        }



复制代码 代码如下:


//定义Row,一行
public class WeekSale_Row
    {
        public string WEEKS;
        public string SKC1;
        public string SKC2;
        public string FCALCSUMS1;
        public string FCALCSUMS2;
        public string NUMS1;
        public string NUMS2;
        public string DISCOUNT1;
        public string DISCOUNT2;
        public string WEEK;
    }

//定义Table
public class WeekSale_Table
    {
        public WeekSale_Row[] row;
    }


感谢各位的阅读,以上就是“怎么调用C#的WebService”的内容了,经过本文的学习后,相信大家对怎么调用C#的WebService这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联网站建设公司,,小编将为大家推送更多相关知识点的文章,欢迎关注!


当前名称:怎么调用C#的WebService-创新互联
链接URL:http://cxhlcq.com/article/ccoedg.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部