2012-04-19 82 views
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]; 

}

+0

您是否尝试执行POST请求SharePoint库? – woody993 2012-06-28 04:44:19

+0

@ woody993有没有可能使用ASIHTTPRequest而无需手动构建SOAP消息(wsdl2obj存根)? – surlac 2012-10-11 10:37:31

+0

@surlac @surlac我上次使用wsdl2obj仅仅一年多,因为后来我编写了一个封闭的源代码库,它使用libxml构造XML负载,所有请求都使用NSURLConnection和操作队列,并使用libxml将响应解析为模型对象。然后我扩展了这个库来构建SharePoint特定的SOAP方法和有效载荷。取决于SharePoint/SOAP的数量,并且如果您不打算使用每种WSDL方法,那么执行此操作也可能是您最好的选择。所以在回答你的问题时,我并不完全确定 – woody993 2012-10-14 07:13:13

回答

相关问题