2010-08-19 224 views
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 
+1

我們來看看您在客戶端上使用的代碼來調用它。 – VoodooChild 2010-08-19 03:34:20

+1

另外,ContactMaster是否可串行化? – Garett 2010-08-19 03:36:48

+0

這不是解決方案,但是您的整個方法可以重寫爲:'return db.ContactMasters.ToList();' – 2010-08-19 04:16:55

回答

0
得到一個錯誤相同的方法

MSDN有一篇用於排除xml序列化問題的文章。有太多的信息要發佈在這裏。我會從他們的文章here開始。

但是,第1步應嘗試到達內部異常,這應該是更具體的。