2012-10-19 33 views
0

下面是請求Web服務的代碼,我收到了反饋@「列表不存在,您選擇的頁面包含一個不存在的列表,它可能已被其他用戶刪除。爲什麼我無法從Web服務獲取數據,我收到了反饋「列表不存在」。

NSString *soapMessage = @"<?xml version=\"1.0\" encoding=\"utf-8\"?><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/\"><soap:Body><GetList xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\"><listName>Contact</listName></GetList></soap:Body></soap:Envelope>"; 

NSString * wsURL = @"http://192.168.11.133/Jason/_vti_bin/Lists.asmx"; 

NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; 
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",wsURL]]; 
ASIHTTPRequest * theRequest = [ASIHTTPRequest requestWithURL:url]; 

[theRequest addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"]; 
[theRequest addRequestHeader:@"SOAPAction" value:@"http://schemas.microsoft.com/sharepoint/soap/GetList"]; 
[theRequest setUsername:@"username"]; 
[theRequest setPassword:@"password"]; 
[theRequest addRequestHeader:@"Content-Length" value:msgLength]; 
[theRequest setRequestMethod:@"POST"]; 
[theRequest appendPostData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 

[theRequest setDefaultResponseEncoding:NSUTF8StringEncoding]; 

[theRequest setTimeOutSeconds:20]; 
[theRequest setDidFailSelector:@selector(onRequestFail:)]; 
[theRequest startSynchronous]; 

該webservice來自sharepoint。 我覺得我的代碼是正確的。任何人都可以提供一些建議謝謝。

+0

你的代碼看起來不錯。您收到的錯誤是服務器錯誤。服務器可能有錯誤。此外,我應該轉向AFNetworking,因爲ASIHTTPRequest不再處於開發階段。 – rckoenes

回答

0

這應該是的SharePoint問題。 直接使用IP會導致一些問題。 我通過映射主機名來解決問題。

1

offtopic:

ASIHTTPRequest不再支持和POST請求的是一類ASIFormDataRequest

請注意,我不再從事這個庫 - 你可能要考慮使用別的東西爲新項目。 :)

你可能在你的替代,如:

相關問題