Exploring OData Feeds from Microsoft Dynamics CRM 2011 Beta Online’s xRM Services
Updated 3/6/2011:
- Oakleaf's Dynamics CRM 2011 beta site is no longer accessible for discovery operations because the beta program terminated last week.
- Rhett Clinton suggested checking out his CRM 2011 OData Query Designer on CodePlex (see Comment).
Updated 9/21/2010 with Dynamics CRM 2011 WCF Web Services and Capturing OData Documents with Fiddler 2 sections.
Originally published 9/21/2010.
Microsoft Dynamics CRM 2011 is the first version to include a full-scale OData provider.
I’ve been testing the Dynamics CRM 2011 Beta Online version’s capability to import Account and Contact data from various file formats to the OakLeaf Systems organization account.
After importing 91 Account and 91 Contact items imported from a comma-separated-values (CSV) file created by Access 2010 from the Northwind Customers table, I had enough content to begin examining the OData feeds with IE 8 and Fiddler 2:
The URLs in this post are examples only. Authentication is required to access Dynamics xRM content; you must be logged into your Dynamics CRM Online account to download OData content with a browser.
Default Collection List
Here (https://oakleafsystems.crm.dynamics.com/xrmservices/2011/organizationdata.svc/) is the entry point to the OakLeaf Systems instance, which identifies 237 collections, of which the first 10 are shown here:
Fiddler 2 reports the response’s body size as ~27 kB. The DynamicsCrmOnlineXrmMetadata.txt contains the data.
Note: The DynamicsCrmOnlineOData.zip file on Windows Live SkyDrive contains all this post’s sample text files.
xRM Metadata
The following URL returns ~3.8 MB of metadata for the EntityTypes listed in the Default https://oakleafsystems.crm.dynamics.com/xrmservices/2011/organizationdata.svc/$metadata feed. Here’s just the first part of the SdkMessageRequestField’s properties:
A DynamicsCrmOnlineXrmMetadata.txt file contains all but the content of the cookies returned by the online data source.
OakLeaf AccountSet
This URL returns 50 Account records for ALFKI through MAISD https://oakleafsystems.crm.dynamics.com/xrmservices/2011/organizationdata.svc/AccountSet/. Here are the first few property values for Alfreds Futterkiste:
The file size is ~1.55 MB, which indicates an average of 31 kB per Account record. The OakLeafXrmAccountSetALFKItoMAISD.txt file contains the data.
ALFKI Single Account Record
This URL returns the Account record for ALFKI https://oakleafsystems.crm.dynamics.com/xrmservices/2011/organizationdata.svc/AccountSet?$filter=Name%20eq%20'Alfreds%20Futterkiste'. Here are more property values for Alfreds Futterkiste:
The OakLeafXrmAccountALFKI.txt file size is 33 kB. The header contributes an additional ~2 kB to a single Account record.
Selected Property Values for ALFKI
The following URL returns ALFKI’s CustomerName, ContactName, City, and Country: https://oakleafsystems.crm.dynamics.com/xrmservices/2011/organizationdata.svc/AccountSet?$select=Name,Address1_PrimaryContactName,Address1_City,Address1_Country&$filter=Name%20eq%20'Alfreds%20Futterkiste':
The OakLeafXrmAccountSubsetALFKI.txt file size is 2 kB. Notice that the Address1_PrimaryContactName value is Maria Anders, but the value doesn’t appear in the Accounts list form’s Primary Contact Name column.
OData Conclusion
Using the $Select instruction to limit the number of property values returned and minimize unnecessary overhead minimizes bandwidth requirements and probably improves performance significantly.
Dynamics CRM 2011 WCF Web Services
The “Introduction to Programming Models for Microsoft Dynamics CRM” topic of the Microsoft Dynamics CRM 2011 SDK states:
Microsoft Dynamics CRM 2011 uses an entity data model and WCF Data Services technologies to provide a new set of tools that simplify the development of Internet-enabled applications that interact with Microsoft Dynamics CRM. This also enables an additional programming paradigm: an organization service context that tracks changes to objects and supports LINQ queries to retrieve data from Microsoft Dynamics CRM.
The https://servernname/xrmservices/2011/discovery.svc?wsdl URI Returns the following details for the IDiscoveryService:
The SDK help file’s “Use IDiscoveryService to Discover the URL for Your Organization” topic provides the following information about the service:
The IDiscoveryService Web service is a global installation-level service that allows the caller to determine the correct organization and URL for their needs. Because Microsoft Dynamics CRM 2011 is a multi-tenant environment, a single Microsoft Dynamics CRM server can host multiple business organizations. Because each server may be handling a Web Service method call for a different organization every time, the Web services must be notified of the target organization that a user is intending to reach.
For a Microsoft Dynamics CRM Online installation, the server cluster typically includes several servers; each may be dedicated to multiple organizations. Ideally, and from a performance perspective, each server has a dedicated Web service URL so that it can be accessed directly through the Internet. However, the Microsoft Dynamics CRM server and organization allocation may change as part of datacenter management and load balancing. Therefore, there is an automated way to discover which Microsoft Dynamics CRM server is serving your organization at a given time. For an on-premises installation, a Web service caller may have access to multiple organizations that may be hosted in different Microsoft Dynamics CRM servers inside the data center.
For both the Microsoft Dynamics CRM Online and Microsoft Dynamics CRM 2011 installations, the IDiscoveryService Web service enables you to discover the IOrganizationService Web service endpoint URL and other information about your target organization.
The IDiscoveryService Web service supports a Web service request to return a list of organizations that the specified user belongs to and the URL endpoint addresses of each organization hosted on the Microsoft Dynamics CRM server.
To access the IDiscoveryService Web service, you simply add a reference to Microsoft.Xrm.Sdk.dll assembly to your Microsoft Visual Studio project, then add a using or imports statement to access the Microsoft.Xrm.Sdk.Discovery namespace.
Capturing OData Documents with Fiddler 2
At the request of several readers, following is a description of how I captured the *.txt files in the DynamicsCrmOnlineOData.zip file.
I used Eric Lawrence’s Fiddler v2.3.0.4 beta Web Debugging Proxy to decrypt the HTTPS request and response traffic and save it as a Notepad *.txt file. Decrypting HTTPS traffic requires choosing Tools | Fiddler Options, clicking the HTTPS tab, and marking the Capture HTTPS Connects, Decrypt HTTPS Traffic and, optionally, Ignore Server Certificate Errors check boxes:
Recent Fiddler 2 beta versions enable trusting the DO_NOT_TRUST_FiddlerRoot certificate to eliminate Certificate Error message in the address bar, as shown in some of the preceding screen captures.
1 comments:
Nice blog. You might like to check out my CRM 2011 ODsts Query Designer on codeplex. Here is the blog post http://bingsoft.wordpress.com/2011/03/06/crm-2011-odata-query-designer-crm2011/
Cheers,
Rhett
Post a Comment