【发布时间】:2016-07-14 07:16:13
【问题描述】:
我在发送具有 3 个属性的对象时遇到问题,问题在于发送时的客户数组我有以下错误对象:
您不能序列化成员。因为它是一个界面。
如果客户 ws 的财产运作良好。 我尝试了各种方法来消除错误,但似乎没有一个工作留下代码片段,以便他们可以给我他们的观点。非常感谢
public class CustomersResponse
{
public bool Success { get; set; }
public string Error { get; set; }
public customer[] ListCustomers { get; set; }
}
ws的代码是
/// <summary>
///
/// </summary>
[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 wsCustomers : System.Web.Services.WebService
{
[WebMethod]
public CustomersResponse CustomersResult()
{
CustomersResponse customers = new CustomersResponse ();
try
{
using (var context = new DataContext())
{
customers.Success = true;
customers .Error = string.Empty;
}
}
catch (Exception ex)
{
customers .Success = false;
customers .Error = ex.Message.ToString();
}
return customers ;
}
}
如果我删除属性 ListCustomers ws 运行良好,如果我标记错误:(
【问题讨论】:
-
customer的定义是什么?是接口还是类? -
你能把代码发给你
customer类吗?该类中是否有可能返回接口的内容?
标签: c# asp.net web-services