【发布时间】:2015-09-30 17:21:45
【问题描述】:
我有一个调用 Web 服务的应用程序,其中 GetDataSourceMappingTable 是一个数据结构,它是一个 data set。
我正在尝试提取某个列 (Users_Tests) 的值,这将为我提供能够调用另一个 Web 服务 GetUser() 的强制参数。
这里有数据集结构:
GetDataTableResponse xmlns="http://tempuri.org/">
<GetDataTableResult>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="SourceID" type="xs:string" minOccurs="0"/>
<xs:element name="Caption" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
我需要调用元素名称"Caption" 并传递值Users_Test(其中Users_Test 是该表中的一个值)以获取SourceID e.g. "Data1"
到目前为止,这是我的代码:
var ds = proxy.GetDataTable();
var DataSourceId = ds.Tables["Table"].Select("Caption = 'Users_test'");
UserData[] userDataId = client.GetUser(ref apiKey, ref message, DataSourceId.ToString()); //GetUserData need the sourceID e.g. Data1 to be able to be used
每当我在GetUser() 中的DataSourceId 变量中运行程序时,方法都没有正确传递。我得到一个数组 0 和 1。在 0 中我得到 Data1,在 1 中我得到 Users_tests。
我想得到例如“数据1”
我如何只能获取 Caption 的值,但将 SourceID 提供给 GetUser() 方法?
我也希望能够拥有多个像我们这样的字幕(Select("Caption = 'Users_test'"); 和 Select("Caption = 'Users_test1'"); 和 Select("Caption = 'Users_test3'");
这可能吗?
谢谢
【问题讨论】:
标签: c# xml web-services dataset