SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have always used jQuery.ajax to retrieve data from listdata.svc or lists.asmx in SharePoint and from some custom web services. Now I will try Microsoft Ajax Library and especially ServiceReference in ASP.NET which can be added to ScriptManager. Then javascript proxy should be created automatically.

Here is my ServiceReference in the masterpage:

<asp:ScriptManager id="ScriptManager" runat="server" 
        <asp:ServiceReference Path="/_vti_bin/lists.asmx" />

When I try this I get the 401 error:

GET http://dev/_vti_bin/lists.asmx/jsdebug 401 (Unauthorized)

enter image description here

Has anyone tried ServiceReference in SharePoint?

EDIT (2012-02-20): I want to call a custom wcf like Wictor Wilén. It works very well with jquery ajax. My custom.svc file is:

<%@ ServiceHost 
    Service="Takana.WCFService,Takana, Version=, Culture=neutral, PublicKeyToken=0c0327f8b01d9792" 
    Factory="Microsoft.SharePoint.Client.ServerRuntime, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

I tried to replace with a simple .NET example, with no success:

<%@ ServiceHost 
    Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
share|improve this question
up vote 3 down vote accepted

The service needs to be AJAX enabled to generate a javascript proxy for you. Lists.asmx is not AJAX enabled.

[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1), WebService(Namespace="")]
public class Lists : GenericService, ISoapServiceLists, ISoapServiceListData, ISoapServiceListSchema, IListSoapServiceContentTypes

For more information see Understanding ASP.NET AJAX Web Services

share|improve this answer
You are right, but when I add my custom wcf service as reference, it doesn't generate any javascript proxy. – Anatoly Mironov Feb 15 '12 at 12:33
You have to make sure you properly configure your custom WCF to auto generate a javascript proxy as well. See and for more information. – Rob Windsor Feb 15 '12 at 14:37
Have you used it with SharePoint, Rob? I just doesn't work here. I added namespace to my contract, added the stuff to web.config. I just wonder if this problem is just sharepoint-related. – Anatoly Mironov Feb 23 '12 at 9:37
Yes. This blog post series -… - has more information. Perhaps it will help. The only thing you might need to change is the security on the service binding. If your SharePoint development machine is running Windows 7 then you'll probably need to use Windows authentication rather than Ntlm. – Rob Windsor Feb 24 '12 at 16:18

Dare i ask why you wouldn't just use SPServices (created by @sympmarc), an open source jQuery plugin that wraps methods in the OOTB SharePoint Web / WCF Services, making the use of these services in JavaScript as simple as the following example:

$(document).ready(function() {
    operation: "GetListItems",
    async: false,
    listName: "Announcements",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
share|improve this answer
Or a straight SharePoint object model call with JavaScript, if you don't want to include jQuery/SPServices in your overhead. – webdes03 Feb 17 '12 at 23:00
Thank you @Colin, I like SPServices and your solution. But I am discovering ASP.NET and SharePoint's built-in possibilities in order to (maybe) improve or (at least) evaluate it. I have used listdata.svc and Client Object Model. I think I'll use more SPServices. But the question remains. What have I to do to enable a native javascript proxy for my web services. – Anatoly Mironov Feb 20 '12 at 9:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.