我正在嘗試構建一個Restful WCF服務。在我的WCF服務中,我引用了包含數據訪問層的1個DLL。WCF REST服務與通用集合
我有以下的方法在我的WCF類
public class Search : ISearch
{
public List<Product> GetProductList()
{
ProductDA dataAccess = new ProductDA();
List<Product> obj = new List<Product>();
obj = dataAccess.GetProducts();
return obj;
}
}
我的界面保持OperationContract的如下:
[ServiceContract]
public interface ISearch
{
[OperationContract]
[WebGet(UriTemplate = "getProductList", RequestFormat = WebMessageFormat.Xml, ResponseFormat WebMessageFormat.Xml)]
List<Product> GetProductList();
}
當我運行在我收到以下錯誤瀏覽器的URL http://localhost:36741/RestService/Search.svc/getFoodTruckNameList: 服務器遇到一個錯誤處理請求
有誰知道正確的代碼來調用[OPERAT ionContract]爲List<Product> GetProductList();
?
在此先感謝。一直拉我的頭髮就這一個了一段時間..
這個錯誤通常意味着你的代碼拋出了一個異常。您是否嘗試過調試您的Web服務? – 2012-03-28 19:37:25
您需要了解有關該錯誤的更多詳細信息,請嘗試附加調試程序併發布異常詳細信息。我的繼承人如何設置/配置WCF用得這可能會給你一些指點http://blog.staticvoid.co.nz/2012/02/using-rest-wcf-service.html – 2012-03-28 19:40:00