I've followed this guide to create and deploy a custom WCF service in Sharepoint 2010 to be consumed in a Visual Web Part using jQuery.
The WCF service's method does several things:
- Make use of SPContext.Current
- Calls some stored procedures using LINQ-to-SQL data context
- Executes some code wrapped in
- Returns a
I've deployed the solution using Visual Studio 2010 Professional in a Sharepoint site that's valid and working.
The problem is when I make the jQuery ajax request I get the login dialog asking for credentials (doesn't like any) and also see a 401 Unauthorized response in Firebug. Also, accessing the same URL through the browser does the same, keeps asking for credentials and if you cancel you get a blank page and 401 Unauthorized in Firebug.
If I change the implementation of the web service's method to return an empty
List<SPFile>, then it works.
I've debugged the whole method step-by-step and it finished without throwing any exceptions. But still getting the Unathorized response.
I'm new at Sharepoint development. I have no idea what the problem is or where to look for it.
I'm using Visual Studio 2010 Professional, Sharepoint 2010 Server, Windows Server 2008 R2 x64