I'm working on a mobile share point application. I'm facing issue while trying to retrieve list collection of a sub-site. Went through so many blogs and tried different approaches but of no use.
My Home site has two sub sites (SampleSubsite & SampleSubsite2) in which I've document libraries created.
The GetSite web service defined in /_vti_bin/SiteData.asmx returns the following response.
Url = "http://sp2010.lab.xyz.local:20852";
Url = "http://sp2010.lab.xyz.local:20852/SampleSubsite";
Url = "http://sp2010.lab.xyz.local:20852/SampleSubSite2";
Now, when I try to fetch the List Collection of a sub site (in this case for example SampleSubsite), I'm constructing the URL as follows.
http://sp2010.lab.xyz.local:20852/SampleSubsite/_vti_bin/Lists.asmx
I've tried multiple options but of no use. (Test is the root site name). In all the below 3 cases, I get the root collection itself.
http://sp2010.lab.xyz.local:20852/Sites/SampleSubsite/_vti_bin/Lists.asmx
http://sp2010.lab.xyz.local:20852/Sites/Test/SampleSubsite/_vti_bin/Lists.asmx
http://sp2010.lab.xyz.local:20852/Test/SampleSubSite/_vti_bin/Lists.asmx
Could anyone through some light on it.
Code snippet Below:
#define kFetchListCollectionXML @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"\
@"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"\
@"<soap:Body>"\
@"<GetListCollection xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />"\
@"</soap:Body>"\
@"</soap:Envelope>"\
- (void)getListCollectionOfSite:(NSString *)sitePath {
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/_vti_bin/Lists.asmx",sitePath]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"http://schemas.microsoft.com/sharepoint/soap/GetListCollection" forHTTPHeaderField:@"SOAPAction"];
[request setValue:[NSString stringWithFormat:@"%ld",(unsigned long)kFetchListCollectionXML.length] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:[kFetchListCollectionXML dataUsingEncoding:NSUTF8StringEncoding]];
[self performConnectionWithRequest:request];
}