Friday, 15.02.2019, 22:03

Engineer M DevelopmentMA

Главная » 2012 » July » 31 » SharePoint on iOS
SharePoint on iOS

How to access SharePoint server from iOS?
For connect and receive data from the web service SharePoiint you can use the ASIHTTPRequest library. Download source code and read documentation here.

The first step is connecting to website on the SharePoiint server. Example URL: . This URL has five parts:
https:// - the URL protocol; - the server name;
mobile/ - the website;
Shared%20Document/ - the item stored on website "mobile";
Forms/AllItems.aspx - the helpers for browsers.

On the website exists user "visitor" with password "123123" and an authentication uses the NTLM scheme. Via ASIHTTPRequest you have to connect to SharePoint, it's doing next code:

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:@""];     
[request setUsername:@"visitor"];     
[request setPassword:@"123123"];     
[request setDelegate:self];     
[request startAsynchronous];

If you want to receive username and password from user via Login Form, then you can use delegate methods:
1) Results of request:
- (IBAction)topSecretFetchFailed:(ASIHTTPRequest *)theRequest 
 [textView setText:[[request error] localizedDescription]]; 
 [textView setFont:[UIFont boldSystemFontOfSize:12]]; 

- (IBAction)topSecretFetchComplete:(ASIHTTPRequest *)theRequest 
 [textView setText:[request responseString]]; 
 [textView setFont:[UIFont boldSystemFontOfSize:12]]; 

2) Authentication Login Form: 
- (void)authenticationNeededForRequest:(ASIHTTPRequest *)theRequest 
 UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Please Login" message:[request authenticationRealm] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil] autorelease];
 [alertView addTextFieldWithValue:@"" label:@"Username"];
 [alertView addTextFieldWithValue:@"" label:@"Password"];
 [alertView show]; 
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
 if (buttonIndex == 1) 
   if ([[self request] authenticationNeeded] == ASIHTTPAuthenticationNeeded) 
     [[self request] setUsername:[[alertView textFieldAtIndex:0] text]];
     [[self request] setPassword:[[alertView textFieldAtIndex:1] text]];
     [[self request] retryUsingSuppliedCredentials]; 
   else if ([[self request] authenticationNeeded] == ASIProxyAuthenticationNeeded) 
     [[self request] setProxyUsername:[[alertView textFieldAtIndex:0] text]]; 
     [[self request] setProxyPassword:[[alertView textFieldAtIndex:1] text]]; 
     [[self request] retryUsingSuppliedCredentials]; 
   [[self request] cancelAuthentication]; 

After successfully access, you can request all List of website. The request making with protocol SOAP. To see examples code of SOAP on your website, you have to visit next directory: "/_vti_bin/Lists.asmx" -> . It's shows you all methods of List Web Service. Now need the method GetListCollection. The request looks like:

 NSString *soapMessage = [NSString stringWithString:@"\n"
"<soap12:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap12=\"\">\n"
"<GetListCollection xmlns=\"\" />\n"

This message have to be encoded and set in post data of Requester 
(it's code for SOAP version 2):

NSURL *url = [NSURL URLWithString:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];     
[request setUsername:@"visitor"];     
[request setPassword:@"123123"];     
[request setDelegate:self];     
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[request addRequestHeader:@"Content-Type" value:@"application/soap+xml; charset=utf-8"];     
[request addRequestHeader:@"Content-Length" value:msgLength];     
[request setRequestMethod:@"POST"];    
[request appendPostData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];     
[request startAsynchronous];

You will receive SOAP answer with Lists from website "mobile" and information about it. From example, it's will be the "Shared Document" List. The information contains more data: Title, Descriptions, Name, Id, urls, dates, type and etc. If you want to get all Items of List then you need attributes 'Id' or 'Name', example: Name="{88299283-69DC-45B2-B4BF-4E5413ED4E50}".
The name you have to use in request at method GetList. Example SOAP:

NSString *listName = [NSString stringWithUTF8String:"88299283-69DC-45B2-B4BF-4E5413ED4E50"];//Shared%20Documents
NSString *soapMessage = [NSString stringWithFormat:@"\n"
"<soap12:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap12=\"\">\n"
"<GetList xmlns=\"\">\n"
, listName];

This string you can set in the previous code. The answer will contain information of Items, it will be files or directories that was shared on the "mobile" website.

Категория: Lessons | Просмотров: 4571 | Добавил: admin | Рейтинг: 5.0/1 |
Всего комментариев: 0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]
Меню сайта
Разделы новостей
Concept Software [2]
Programs are planned or under construction.
Software [10]
Release Software
Lessons [12]
About Me [1]
Infa about yourself, documents, certificates ...
Documentation [4]
Documentation of projects
Календарь новостей
«  July 2012  »
Друзья сайта
Copyright Macarov Anatoli © 2019
Free website builderuCoz