1
我一直在嘗試使用sharepoint web服務(來自webs.asmx)GetWebCollection獲取用戶可用網站的列表。我用sharepoint成功地進行了身份驗證,如果我在站點路徑中進行硬編碼,則可以返回文件。但是,當我嘗試使用GetWebCollection時,我收到了「403 Forbidden」錯誤?獲取SharePoint中可供用戶使用的網站列表
需要改變什麼?
另外,有沒有什麼辦法可以告訴用戶自動分配給哪個站點?
我在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];
}
您是否嘗試執行POST請求SharePoint庫? – woody993 2012-06-28 04:44:19
@ woody993有沒有可能使用ASIHTTPRequest而無需手動構建SOAP消息(wsdl2obj存根)? – surlac 2012-10-11 10:37:31
@surlac @surlac我上次使用wsdl2obj僅僅一年多,因爲後來我編寫了一個封閉的源代碼庫,它使用libxml構造XML負載,所有請求都使用NSURLConnection和操作隊列,並使用libxml將響應解析爲模型對象。然後我擴展了這個庫來構建SharePoint特定的SOAP方法和有效載荷。取決於SharePoint/SOAP的數量,並且如果您不打算使用每種WSDL方法,那麼執行此操作也可能是您最好的選擇。所以在回答你的問題時,我並不完全確定 – woody993 2012-10-14 07:13:13