Friday, May 18, 2012

A Quick Look at OData

Posted in [Dynamics CRM], [Technical] By Matt Wittemann @ 9/9/2010 5:15 PM

SharePoint 2010 and the upcoming Dynamics CRM 2011 are two of Microsoft's premier products that are leveraging the new Open Data protocol,or OData. At C5 Insight, we focus on SharePoint and CRM, so we're excited about diving into OData and finding ways to use it to enhance our clients' investments in these systems.

OData is an open-source standard for performing read, create and update operations using nothing more than querystring parameters appended to a URL. A RESTful architecture, it's the evolution of Microsoft's ADO.NET Data Services. Data sources like SharePoint lists and CRM tables can be enabled for OData access using the .NET Framework 4's Windows Communication Foundation.

OData uses standard HTTP messages (GET, PUT, POST, and DELETE) combined with the OData syntax to make it easy to connect web-based applications. To use OData, you address the data service's endpoint. This is essentially a URL, something like www.foo.com/mydata.svc. Browsing to this address would bring back an XML feed that you could read in your browser or reference in code.

Inside each data service endpoint will be collections or sets of data. You can think of them as the lists or tables. For example, there might be a "documents" set. So if you were to browse to foo.com/mydata.svc/documents you'd get an XML feed that contained the document data. OData endpoints also provide access to metadata. The standard way to access this would be to browse to the data service endpoint and then add the /$metadata parameter (foo.com/mydata.svc/$metadata).

To query a data collection or add or update records, you add the query parameters. OData has a syntax for this. A simple example is to select the top five records: $top=5 (foo.com/mydata.svc/documents?$top=5). You can combine query parameters as well, so you can do more complex queries.

In Microsoft Dynamics CRM 2011, each organization will have its own OData service address, and each entity will be represented as a "set" under the OData service. The URIs for CRM 2011's OData service look like this:

  • The main OData service: http://crmserver/orgname/xrmservices/2011/organizationdata.svc
  • The metadata URI: http://crmserver/orgname/xrmservices/2011/organizationdata.svc/$metadata
  • Accessing the Account data set: http://crmserver/orgname/xrmservices/2011/organizationdata.svc/AccountSet
  • A query that returns the account number and city for an account named "Advanced Components": http://crmserver/OrgName/xrmservices/2011/organizationdata.svc/AccountSet?$select=AccountNumber,Address1_City&$filter=Name eq 'Advanced Components'

Here's the XML the query above would return:

References:

Popular tags: ,

Comments

Got something to say? Join the discussion »
    Posted by RhettClinton on 3/6/2011 7:06 AM
    Nice blog. You might like to check out my CRM 2011 ODsts Query Designer on codeplex. Here is the blog post bingsoft.wordpress.com/.../

    Cheers,
    Rhett
    Posted by Arvind on 10/18/2010 7:14 AM
    Wow ...... this is great news.
    I was just thinking that someone would suggest oData service creation for MS CRM but now MS itself is coming up with this in the new version of their product.

leave a reply

 [Quick Submit with Ctrl+Enter]

Remember my details
Notify me of followup comments via e-mail

C5_Insight

About C5 Insight

We are a Microsoft Gold Certified partner focusing on SharePoint, Microsoft Dynamics CRM and Salesforce.com.  Learn more about us by visiting our website.

Search

We Wrote the Bible on Microsoft SharePoint and Dynamics CRMBook-Microsoft Dynamics CRM 2011 and SharePoint 2010 Bible

Tags

Maximize

Recent Comments

Maximize

Blog Roll

Maximize

Disclaimer

The information herein may be used solely at your own risk.  No warranty is made by the author or by C5 Insight, Inc.

The opinons expressed herein are those of the individual authors and do not necessarily represent C5 Insight, Inc in any way.

Copyright 2011 by C5 Insight