Sharepoint:GetList listName返回所有列表

时间:2013-06-11 13:13:44

标签: objective-c sharepoint

我最初的肥皂电话是获取所有列表:

//init the soap call format - this gets us all the list on the mobiledev sharepoint
soapFormat = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
        "<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/\">\n"
        "<soap:Body>\n"
        "<GetListCollection xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />\n"
        "</soap:Body>\n"
        "</soap:Envelope>\n"];

然后我找到了我要查找的特定列表,并再次调用以获取该列表的内容:

if([[attributeDict objectForKey:@"Title"] isEqualToString:@"SharePoint Data Test"]) {

        //get the list name
        NSString* strListName = [attributeDict objectForKey:@"Name"];

        //reset the soap call to get the list data we are looking for
        soapFormat = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
              "<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/\">\n"
              "<soap:Body>\n"
              "<GetList xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">\n"
              "<listName>%@</listName>\n"
              "<QueryOptions>\n"
              "<IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>"
              "<ViewAttributes Scope=\"RecursiveAll\"/>"
              "</QueryOptions>\n"
              "</GetList>\n"
              "</soap:Body>\n"
              "</soap:Envelope>\n", strListName];

        [self getData];

但是这又回来了。我是否必须编写查询才能获得我要查找的列表? (另外,如果您觉得慷慨,返回的数据不包含列表内容,只是它的元数据/属性,如第一次调用。)

1 个答案:

答案 0 :(得分:1)

解决了它,所以我要发帖给别人参考:

问题出在我的NSMutableURLRequest:

NSMutableURLRequest* theRequest = [[NSMutableURLRequest alloc]initWithURL:locationOfWebService];

    NSString *msgLength = [NSString stringWithFormat:@"%d",[soapFormat length]];


    [theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue:@"http://schemas.microsoft.com/sharepoint/soap/GetListItems" forHTTPHeaderField:@"SOAPAction"];//<--make sure you change this line to the web service query you are using (in this case GetListItems
    [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    //the below encoding is used to send data over the net
    [theRequest setHTTPBody:[soapFormat dataUsingEncoding:NSUTF8StringEncoding]];


    NSURLConnection *connect = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];