Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have just started sharepoint development using cloudshare. Now i am stuck trying to run the code below:

myListService.Url = "http://sp2010/_vti_bin/Lists.asmx";

XmlNode myListView = myListService.GetListAndView("Customers", "");

I get an exception on the second line saying something like "ListNotFound"

I have tried different web ref urls, but still not working e.g.

'http://sp2010/_vti_bin/Lists.asmx'

'http://sp2010:8080/_vti_bin/Lists.asmx'

'http://localhost/_vti_bin/Lists.asmx'

This is my page url -

'http://sp2010:8080/personal/joe/SitePages/Home.aspx'

If i try this with Tasks it works fine, but when i call 'GetListItems' it is empty (even though i have manually added some).

Anyone got any ideas?

share|improve this question
add comment

1 Answer

I dunno if the url that you are passing is correct.. can you try the following?

The code is getting the true url and adding the webservice at the end. It should return the correct webservice url regardless of what it is :)

string hostURL = null;
hostURL = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);

hostURL = hostURL + "/_vti_bin/Lists.asmx";

myListService.Url = hostURL;

XmlNode myListView = myListService.GetListAndView("Customers", ""); 

Hope it helps :)

share|improve this answer
add comment

Your Answer

 
discard

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.