How to use MS CRM 2011 web services in iOS?

I would like to create an iPad application for MS Dynamics CRM 2011. We have a CRM system where you can enter anywhere in the world with an AD username and password.

I know CRM comes with the Discovery service, organization service, and OData service. But I do not know how to use these services? I would like to know how should I authenticate a user?

Here is an example of the code that I found but does not work. :(

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);}]; } 

Thank you for your help.

+4
source share
2 answers

Most implementations and products I've seen use a mediation server or service for proxy calls in CRM. The REST service is available in order for general CRUD operations, but does not have the features that other SDKs provide.

Benefits:

  • Implement the SDK that best supports the customers you want to support
  • You get the full range of features available in any of the CRM SDKs.

Disadvantages:

  • It can be a lot of work.

If you need to connect directly from the client to the CRM installation. Consider accessing the OData source through a browser when capturing traffic using a local proxy or browser DEV tools. Write code that creates the same web requests. Theoretically, it is as safe as using a browser to access CRM. Use appropriate tools to encrypt, mask and obscure traffic.

There are other alternatives that I personally have not experienced. I can offer them for research, but I can not speak with confidence about them.

MSDN: REST 2011 CRM Service Documentation

MSDN: CRM 2011 SDK Review

0
source

If you try to authenticate with Dynamics CRM from iOS initially, you will need a lot of time ... and when I say a lot, LOT.

There are different CRM configurations On-Premise / On-line, and it will be even more complicated with IFD and https (where you really need to authenticate against ADFS, check the certificate chain ... etc.).

The easiest way to start is that you can open the proxy web service, implemented in .NET, which is dedicated to authentication against CRM for you, and then authenticate this web service from your iOS application (using a simple https request and a simpler authentication mechanism)

But even doing this is still a lot of time.

0
source

Source: https://habr.com/ru/post/1440107/


All Articles