500 HTTP Error on Lists.asmx in subsite context

Oct 17, 2014 at 4:29 PM
Hi,

I am developing a custom SharePoint 2007 solution using the SPServices library and trying to retrieve all the items of a list existing in a subsite. The page where the code executes is also in the subsite context. However, when I execute the code (SPServices.SPGetListItemsJson method), I get the 500 error on /rootsite/subsite/vti_bin/Lists.asmx not found.

Would really appreciate some help with this.
Coordinator
Oct 17, 2014 at 4:31 PM
Can you post the code?

M.
Oct 17, 2014 at 4:43 PM
Hi sympmarc, thanks for your prompt response. Here is my code. It is a simple call to the SPGetListItemsJson method:
           var camlQuery = "<Where><Eq><FieldRef Name='TestFinished'/><Value Type='Text'>Done</Value></Eq></Where>";
    var listItems = $().SPServices.SPGetListItemsJson({
    async: false,
    listName: "Tests",
    //listname: "{E73FEA09-CF8F-4B30-88C7-6FA996EE1706}",
    //webURL: $().SPServices.SPGetCurrentSite(),
    //webURL: "http://"+location.host + "/_vti_bin/lists.asmx",
    //webURL: "/mysitecollection/mysubsite",
    CAMLQuery: camlQuery
    });
    alert(JSON.stringify(listItems));
I believe that since the Lists.asmx only exists in the root site, there should be a way to specify different weburls for the list in question and for accessing the Lists.asmx present in the root site. I have also tried all combinations listed in the commented out lines as well.
Coordinator
Oct 17, 2014 at 4:49 PM
Edited Oct 17, 2014 at 4:51 PM
That looks like it ought to work. You can call the Lists Web Services from any context. If you don't specify the webURL, then the current site's URL is used.

Try a simpler test:
$().SPServices({
  operation: "GetListItems",
    async: false,
    listName: "Tests"
});
Look in the Net tab of Firebug (or whatever you choose to use) to see the traffic.

M.
Oct 17, 2014 at 4:51 PM
Yes, I have tried omitting the webUrl all together and then I still get the 500 error on /rootsite/subsite/vti_bin/Lists.asmx not found.
Coordinator
Oct 17, 2014 at 4:52 PM
It's possible (but not likely) that Web Services are disabled in your environment.

M.
Oct 17, 2014 at 5:19 PM
Thanks, I guess that could be the issue.
Oct 17, 2014 at 5:49 PM
Edited Oct 17, 2014 at 5:50 PM
I just tried the simpler test as suggested:

$().SPServices({
operation: "GetListItems",
async: false,
listName: "Tests"
});

In the Net tab, i observe that this makes call to the /sitecollection/subsite/_vti_bin/Lists.asmx and I get HTTP 200 Ok. This atleast indicates that the Lists webservices are not disabled. But I do not understand why I do I get HTTP 500 with SPServices.SPGetListItemsJson().

Any other tips appreciated!
Coordinator
Oct 17, 2014 at 5:58 PM
I really don't know. Take a look at the Net traffic for that call and make sure the POST looks valid.

M.
Oct 17, 2014 at 7:02 PM
Just discovered the point of failure. If I comment out the CAMLQuery argument in the call to the $().SPServices.SPGetListItemsJson(), it fetches the Lists.asmx. If I add the CAMLQuery property to the call to the simpler $().SPServices, even that fails with the same 500 error.

I have double checked my caml query and the details about the field name that I am referring to. It all seems correct.
Oct 17, 2014 at 7:16 PM
Update: The query works when it is put in this form:

var camlQuery = "<Query><Where><Eq><FieldRef Name='TestFinished' />"+"<Value Type='Text'>Done</Value></Eq></Where></Query>";
Coordinator
Oct 17, 2014 at 7:38 PM
Sorry; I didn't spot that mistake. Your query does have to be valid CAML.

Sounds like you're all set now.

M.
Oct 17, 2014 at 7:48 PM
Things starting to work now. But alert(JSON.stringify(listItems)); returns an empty JSON object. I have indeed looked at your example on https://spservices.codeplex.com/wikipage?title=$().SPServices.SPGetListItemsJson as follows:

var camlQuery = "<Query><Where><Eq><FieldRef Name='TestFinished'/>"+"<Value Type='Text'>Done</Value></Eq></Where></Query>";
    var listItems = $().SPServices.SPGetListItemsJson({
    async: false,
    listName: "Project Records Turnover Plan Log",
    CAMLQuery: camlQuery,
     mappingOverrides: {
    ows_TestFinished: {
        mappedName: "Test Finished",
        objectType: "JSON"
    },
    ows_CandidateName: {
        mappedName: "Name",
        objectType: "JSON"
    }
}
});

alert(JSON.stringify(listItems));

When I look at the data returned in the web service response, it does contain all the required list data as text/xml. Thanks for all your help!