【发布时间】:2013-05-30 06:33:52
【问题描述】:
我的网络服务正在返回所有字符串变量。现在我想修改我的服务,以便它可以返回 HashTable 对象。这是我的 WebService 入口点(方法)的签名:
public void getPrevAttempts(string fbUserId, string studentId, string assessmentId, out string isAuthenticated, out HashTable attempts)
HashTable 中的记录是从 SQL 查询的结果中插入的。每当我尝试运行我的服务时,我都会被重定向到 accessdenied.htm 页面(因为我的 Web.config 有这个条目 <customErrors mode="On" defaultRedirect="accessdenied.htm"/>)。有没有什么方法可以返回HashTable或者SQL查询的结果?
更新:
例外:The type System.Collections.Hashtable is not supported because it implements IDictionary.
【问题讨论】:
-
服务返回的错误是什么?
-
HashTable,90 年代又来了…… -
我很确定 Web 服务签名中不支持
out参数。您也可能会遇到序列化问题,尤其是跨平台(字符串是普遍已知的类型,但 .Net Hashtable 不是)。但是,哈希表 被标记为可序列化,所以我会尝试的第一件事是将其用作返回值。 -
您可以返回
DataSet或DataTable -
@Tim Medora:支持
out参数。是否应该由 Web 服务方法使用它们是另一回事。
标签: c# web-services