1

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

//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];

但这又将一切归还。我是否必须编写查询才能获得我正在寻找的列表?(另外,如果你觉得大方,返回的数据不包含列表内容,而只是它的元数据/属性,就像第一次调用一样。)

4

1 回答 1

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];
于 2013-06-11T16:08:28.527 回答