我一直在尝试使用 sharepoint Web 服务(来自 webs.asmx)GetWebCollection 来获取用户可用的站点列表。我已经使用 sharepoint 成功进行了身份验证,如果我在站点路径中进行硬编码,我可以取回文件。但是,当我尝试使用 GetWebCollection 时出现“403 Forbidden”错误?
需要什么不同的下来?
或者,有什么方法可以告诉用户自动分配到哪个站点?
我在 Objective-C 中通过 SOAP(使用 ASIHTTPRequest)进行连接。
- (void)getUrl {
NSURL *url = [NSURL URLWithString:@"https://[server]/_vti_bin/Webs.asmx"];
requestGetSites = [ASIHTTPRequest requestWithURL:url];
[requestGetSites setDelegate:self];
NSString *soapMessage = @"<?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"
"<GetWebCollection xmlns=\"http://schemas.microsoft.com/sharepoint/soap\" />\n"
"</soap:Body>\n"
"</soap:Envelope>";
[requestGetSites setUseCookiePersistence:NO];
[requestGetSites setUsername:@"username"];
[requestGetSites setPassword:@"password"];
[requestGetSites appendPostData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[requestGetSites addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[requestGetSites addRequestHeader:@"Host" value:@"[a server]"];
[requestGetSites addRequestHeader:@"SOAPAction" value:@"http://schemas.microsoft.com/sharepoint/soap/GetWebCollection"];
NSLog(@"Request headers are: %@", [[requestGetSites requestHeaders] description]);
[requestGetSites startSynchronous];
}