我对C不熟悉,并且尝试使用SOAP Web服务,我生成了对WSDL的服务引用,并且能够执行以下操作来检索响应的数据集。
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;
我在这里错过了什么步骤?