Webservice 获取数据的写法
/// <summary>
/// 获取NC系统数据
/// </summary>
/// <returns></returns>
[WebMethod]
public string GetDate(string start, string end)
{
StringBuilder xml = new StringBuilder();
xml.Append("<?xml version='1.0' encoding='gbk' ?>");
xml.Append("<Donationlist>");
try
{
List<RcscbbDonation> ncDonation = RcscbbDonationUtility.GetDataByDate(start, end);
if (ncDonation != null)
{
foreach (var item in ncDonation)
{
#region--------通过便是节点名称来分类数据-------
xml.Append("<DonationInfor>");
if (item.DonationMemo != null)
xml.Append("<DonationMemo>" + item.DonationMemo + "</DonationMemo>");
if (item.DonationNo != null)
xml.Append("<DonationNo>" + item.DonationNo + "</DonationNo>");
if (item.DonorName != null)
xml.Append("<DonorName>" + item.DonorName + "</DonorName>");
if (item.DonationMoney != null)
xml.Append("<DonationMoney>" + item.DonationMoney + "</DonationMoney>");
if (item.DonationProject != null)
xml.Append("<DonationProject>" + item.DonationProject + "</DonationProject>");
if (item.ProjectFICode != null)
xml.Append("<ProjectFICode>" + item.ProjectFICode + "</ProjectFICode>");
if (item.DonationDate != null)
xml.Append("<DonationDate>" + item.DonationDate + "</DonationDate>");
if (item.DonationTime != null)
xml.Append("<DonationTime>" + item.DonationTime + "</DonationTime>");
if (item.DonationType != null)
xml.Append("<DonationType>" + item.DonationType + "</DonationType>");
if (item.RecipientsID != null)
xml.Append("<RecipientsID>" + item.RecipientsID + "</RecipientsID>");
if (item.IssuingPersonID != null)
xml.Append("<IssuingPersonID>" + item.IssuingPersonID + "</IssuingPersonID>");
if (item.EnterPersonID != null)
xml.Append("<EnterPersonID>" + item.EnterPersonID + "</EnterPersonID>");
if (item.InvoiceID != null)
xml.Append("<InvoiceID>" + item.InvoiceID + "</InvoiceID>");
if (item.InvoiceCode != null)
xml.Append("<InvoiceCode>" + item.InvoiceCode + "</InvoiceCode>");
if (item.InvoiceAccount != null)
xml.Append("<InvoiceAccount>" + item.InvoiceAccount + "</InvoiceAccount>");
if (item.InvoiceBank != null)
xml.Append("<InvoiceBank>" + item.InvoiceBank + "</InvoiceBank>");
if (item.InvoicePrintState != null)
xml.Append("<InvoicePrintState>" + item.InvoicePrintState + "</InvoicePrintState>");
if (item.RemittanceNumber != null)
xml.Append("<RemittanceNumber>" + item.RemittanceNumber + "</RemittanceNumber>");
if (item.DonationState != null)
xml.Append("<DonationState>" + item.DonationState + "</DonationState>");
if (item.WhetherRepresent != null)
xml.Append("<WhetherRepresent>" + item.WhetherRepresent + "</WhetherRepresent>");
if (item.RepresentName != null)
xml.Append("<RepresentName>" + item.RepresentName + "</RepresentName>");
if (item.RepresentPhone != null)
xml.Append("<RepresentPhone>" + item.RepresentPhone + "</RepresentPhone>");
if (item.RepresentAddress != null)
xml.Append("<RepresentAddress>" + item.RepresentAddress + "</RepresentAddress>");
if (item.VouchersNo != null)
xml.Append("<VouchersNo>" + item.VouchersNo + "</VouchersNo>");
if (item.VouchersOperater != null)
xml.Append("<VouchersOperater>" + item.VouchersOperater + "</VouchersOperater>");
if (item.VouchersDate != null)
xml.Append("<VouchersDate>" + item.VouchersDate + "</VouchersDate>");
if (item.VouchersTime != null)
xml.Append("<VouchersTime>" + item.VouchersTime + "</VouchersTime>");
if (item.CreateDate != null)
xml.Append("<CreateDate>" + item.CreateDate + "</CreateDate>");
if (item.CreateTime != null)
xml.Append("<CreateTime>" + item.CreateTime + "</CreateTime>");
xml.Append("</DonationInfor>");
#endregion
}
}
xml.Append("</Donationlist>");
}
catch (Exception ex)
{
LogUtility.Log_InFile("StackTrace:" + ex.StackTrace + " Message:" + ex.Message + " Source:" + ex.Source, Enumlevel.e_Error, EnumLogType.Log_Exception, false);
return null;
}
return xml.ToString();
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
aspx.cs 文件中如何获取Webservice读出的数据方式
protected void BindGrid()
{
WebSystem.ServiceReference1.ncwebserviceSoapClient ncdata = new ServiceReference1.ncwebserviceSoapClient();
service = ncdata.NClist(StartDate, EndDate);//关联服务的方法
List<RcscbbDonation> rcscbbList = new List<RcscbbDonation>();
if (!string.IsNullOrEmpty(service))
{
XmlDocument document = new XmlDocument();
document.LoadXml(service);
XmlNodeList donNodeList = document.SelectNodes("Donationlist")[0].ChildNodes;//获取XML节点
foreach (XmlNode item in donNodeList)
{
RcscbbDonation rcscbbDonation = new RcscbbDonation();
XmlNodeList InforList = item.ChildNodes;
foreach (XmlNode infor in InforList)
{
switch (infor.Name)
{
case "DonorName":
rcscbbDonation.DonorName = infor.InnerText.Trim();
break;
}
}
}
}
}
浙公网安备 33010602011771号