0
我有一個單一的WebMethod將返回列表對象如下圖所示Web服務客戶端的問題
[WebMethod]
public List<ContactMaster> GetContacts()
{
//ContactMaster contact = new ContactMaster();
List<ContactMaster> contacts=new List<ContactMaster>();
IQueryable<ContactMaster> contact = from c in db.ContactMasters
select c;
foreach (ContactMaster c in contact)
{
contacts.Add(c);
}
return contacts ;
}
當我嘗試調用來自客戶端,我如下
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException
我們來看看您在客戶端上使用的代碼來調用它。 – VoodooChild 2010-08-19 03:34:20
另外,ContactMaster是否可串行化? – Garett 2010-08-19 03:36:48
這不是解決方案,但是您的整個方法可以重寫爲:'return db.ContactMasters.ToList();' – 2010-08-19 04:16:55