我想为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);}];
}
感谢您的帮助。
我见过