我想爲MS Dynamics CRM 2011創建一個iPad應用程序。我們有一個CRM系統,您可以使用AD用戶名和密碼在世界任何地方登錄。如何在iOS中使用MS CRM 2011 Webservices?
我知道CRM附帶發現服務,組織服務和OData服務。但我不知道如何使用這些服務?我想知道我應該如何驗證用戶?
這是我發現的,但不工作的樣本代碼。:(
NSString *username = @"domain/username";
NSString *password = @"password";
NSString *loginURL = @"http://server/OrgName/XRMServices/2011/OrganizationData.svc/";
NSURL *url = [NSURL URLWithString:loginURL];
NSString *JSONString = [NSString stringWithFormat:@"{\"user id\":\"%@\",\"password\":\"%@\"}", username, password];
NSData *JSONBody = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *loginRequest = [[NSMutableURLRequest alloc] initWithURL:url];
loginRequest.HTTPMethod = @"POST";
loginRequest.HTTPBody = JSONBody;
NSOperationQueue *queue = [NSOperationQueue new];
[NSURLConnection sendAsynchronousRequest:loginRequest
queue:queue
completionHandler:^(NSURLResponse *response, NSData *data,
NSError *error){
// Manage the response here.
[self fetchedData:data];
NSLog(@"error:%@", error);
NSLog(@"response:%@", response);}];
}
感謝您的幫助。
我見過