【发布时间】:2014-06-28 06:12:00
【问题描述】:
我有一个带有这样的 webmethod 的 web 服务:
网络服务:
[WebMethod]
public List<ProcessQueue> GetTasks(int ShopId)
{
List<ProcessQueue> p = new List<ProcessQueue>();
p.Add(new ProcessQueue {shopId="shop1", process="process1"});
p.Add(new ProcessQueue {shopId="shop2", process="process2"});
return p;
}
public class ProcessQueue
{
public string shopId { get; set; }
public string process { get; set; }
}
我还有一个正在使用 Web 服务的 Windows 窗体应用程序:
我按照Consume a web service中描述的步骤进行操作
Windows 窗体:
using (var svc = new Service1SoapClient())
{
var result = svc.GetTasks(7);
MessageBox.Show(result.ToString());
}
现在我可以使用 Web 服务,但我面临的唯一问题是我无法在我的 Windows 窗体应用程序中将结果作为字符串获取。
我会怎么做。有什么帮助吗?
【问题讨论】:
-
你想如何将列表转换为字符串?
-
我想在winform中获取shopId和process的值,我该如何实现呢?我不想将列表转换为字符串。
-
好的,假设您的服务返回了 2 行,您期望的输出字符串是什么?
-
我自己找到了解决方案。请查看我的更新
标签: c# winforms web-services class