0
votes

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];
}
2

2 Answers

0
votes

The issue worked fine after creating the Alternate Access Mapping and creating the request for the the subsites as follows:

For subsite "SampleSubsite" with URL "http://sp2010.lab.xyz.local:20852/SampleSubsite", the request URL should be constructed as follows.

http://sp2010.lab.xyz.local:20852/SampleSubsite/_vti_bin/Lists.asmx

0
votes

I was struggling with this using the New-WebServiceProxy cmdlet. The problem went away when I added ?WSDL to the end of the query string, as suggested here http://blogs.msdn.com/b/powershell/archive/2010/06/24/using-new-webserviceproxy-to-get-modify-and-add-items-to-a-list-in-sharepoint-2007.aspx