您好,登錄后才能下訂單哦!
這篇文章主要講解了“怎么調用C#的WebService”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“怎么調用C#的WebService”吧!
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這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。