【发布时间】:2011-05-16 23:07:54
【问题描述】:
我创建了一个简单的服务来提供配置选项作为字典。我创建了一个新的 SerializableDictionary 类,该类实现了本板上描述的 IXmlSerializable。当我添加服务时(通过我的消费者项目中的“添加服务引用”),方法签名显示它返回一个 DataSet。当我在运行时检查 DataSet 时,它是空的。
这是我的服务:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class AppSettingsService : System.Web.Services.WebService
{
[WebMethod]
public SerializableDictionary<string, string> ReadAppSettings()
{
return AppSettings.Settings; // Settings is a SerializableDictionary<string, string>
}
}
在客户端我这样做:
using Clients.AppSettingsServiceReference;
static AppSettings()
{
AppSettingsServiceSoapClient client = new AppSettingsServiceSoapClient();
var settings = client.ReadAppSettings();
// ...
}
我希望 settings 是一个 SerializableDictionary,但它是一个空的 DataSet。我已尝试按照此处和其他地方的建议将其作为 KeyValuePairs 列表发送,但这也返回了一个 DataSet。我正在使用 C#、ASP.Net 3.5、VS2008 Pro 我确定我忽略了一些简单的东西,但我找不到它。有人可以告诉我怎么做吗?
【问题讨论】:
标签: .net web-services asmx