Connecting to Microsoft Dynamics CRM Offline

Microsoft Dynamics CRM also allows for offline access of its Web service APIs. Working with the offline APIs is no different from working with their online counterparts, except you will need to access the Web services from a local URL. Simply use the registry to construct the proper URL and to retrieve the organization name as shown in the following code:

//Retrieve the Port and Organization Name from the Registry
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(
       "Software\Microsoft\MSCRMClient"))
{
    string orgName = key.GetValue("ClientAuthOrganizationName").ToString();
    string port = key.GetValue("CassiniPort").ToString();

    //Construct the URL
    UriBuilder uriBuilder = new UriBuilder("http", "localhost");
    uriBuilder.Port = int.Parse(port);
    uriBuilder.Path = "/mscrmservices/2007/";
    string crmServiceUrl = url.ToString() + "crmservice.asmx";
    string metadataServiceUrl = uriBuilder.ToString() + "metadataservice.asmx";

    //Connect to the service objects...
}

Note

Note

The Microsoft Dynamics CRM Outlook client only allows access to a single organization.

For more information regarding offline development, see Chapter 10.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset