【发布时间】:2019-01-04 09:57:06
【问题描述】:
我是 C# 新手,尝试使用 SOAP Web 服务,我生成了对 WSDL 的服务引用,并且能够执行以下操作来检索响应的 DataSet。
SportingGatewaySoapClient myServices = new SportingGatewaySoapClient("GatewaySoapID");
RSportResults sportsResults = myServices.SportResults("username","password");
System.Data.DataSet dataSet = sportsResults.dsSportResults;
如果我像往常一样遍历数据集,我就能看到正确的信息:
foreach (DataTable table in dataSet.Tables)
{
foreach (DataRow row in table.Rows)
{
foreach (object item in row.ItemArray)
{
Console.WriteLine(item);
}
}
}
但我看不到如何将数据直接解组到生成的类中,以便我可以按名称引用它的属性。例如:
// some code here to convert response to a Sport object
sport.getSportName()
自动生成的 Reference.cs 文件有这样的类:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="https://endpointurl")]
public partial class RSport : object, System.ComponentModel.INotifyPropertyChanged {
private string sportName;
我在这里错过了什么步骤?
【问题讨论】:
标签: c# web-services soap