<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/OData+Support">OData Support</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://docs.jboss.org/author/display/~shawkins">Steven Hawkins</a>
    </h4>
        <br/>
                         <h4>Changes (44)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h3. How to Access the data? <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">For example, if you have a vdb by name _northwind_ deployed and that vdb has a table _customers_ in a model called _NW_ then you can access that table as <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">For example, if you have a vdb by name _northwind_ deployed that has a _customers_ table in a _NW_ model, then you can access that table with an HTTP GET via the URL: <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">this would be akin to, making a JDBC/ODBC connection and issuing a SQL call as <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">this would be akin to making a JDBC/ODBC connection and issuing the SQL: <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code:lang=SQL} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{tip} <br></td></tr>
            <tr><td class="diff-changed-lines" >Note that you <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">need to</span> <span class="diff-added-words"style="background-color: #dfd;">should</span> fully qualify the table name along with the model name. Also, use correct case (upper or lower) as used in the VDB. <br></td></tr>
            <tr><td class="diff-unchanged" >{tip} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">the returned results from OData query can be in Atom/AtomPub XML format or JSON format. By default AtomPub based XML result is returned. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">the returned results from OData query can be in Atom/AtomPub XML or JSON format. AtomPub XML results are returned by default. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{warning:title=Seeing &quot;EdmEntitySet Not Found&quot; error?} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;/error&gt; <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" >Then, it means that either you supplied the model-name.table-name combination wrong, check spelling and case. Or your table did not have any PRIMARY KEY or UNIQUE KEY(s) on them. Since OData access is more key oriented, it is * MANDATORY\* that every table Teiid exposes through OData <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">interface</span> must have a PK or at least one UNIQUE key. Note that Teiid does support composite PRIMARY <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">KEY too.</span> <span class="diff-added-words"style="background-color: #dfd;">KEYs.</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{warning} <br> <br>{note:title=Not seeing all the rows?} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">See the configuration section below for more details. Issue another call as <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">See the configuration section below for more details. Issue another call with the same URL, but with the $skiptoken query option specified from the previous result: <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">http://localhost:8080/odata/northwind.1/NW.customers?$skiptoken=256</span> <span class="diff-added-words"style="background-color: #dfd;">http://localhost:8080/odata/northwind.1/NW.customers?$skiptoken=xxx</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>{note} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">To request the result to be formatted in JSON, add: $format=json after the &quot;?&quot; in the URL <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Users can submit criteria with along their query to filter the results: <br> <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">http://localhost:8080/odata/northwind.1/NW.customers?$filter=name eq &#39;bob&#39; <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">http://localhost:8080/odata/northwind.1/NW.customers?$format=JSON</span> <span class="diff-added-words"style="background-color: #dfd;">{code}</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">or with criteria <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">this would be similar to making a JDBC/ODBC connection and issuing the SQL <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">http://localhost:8080/odata/northwind.1/NW.customers?$filter=name eq &#39;bob&#39;&amp;$format=JSON <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code:lang=SQL} <br>SELECT * FROM NW.customers where name = &#39;bob&#39; <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Users can also submit criteria with along their query to filter the results <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">To request the result to be formatted in JSON, add the query option $format=json <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">http://localhost:8080/odata/northwind.1/NW.customers?$filter=name eq &#39;bob&#39; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">http://localhost:8080/odata/northwind.1/NW.customers?$format=JSON <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">this would be akin to, making a JDBC/ODBC connection and issuing a SQL call as <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Query options can be combined as needed.  For example format with a filter: <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{code:lang=SQL} <br>SELECT * FROM NW.customers where name = &#39;bob&#39; <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">http://localhost:8080/odata/northwind.1/NW.customers?$filter=name eq &#39;bob&#39;&amp;$format=JSON <br>{code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The power of OData querying comes from navigations from one entity to another, similar the foreign key relationships in the relational databases. For example, if _customers_ table had a association with _orders_ table, where say _customers_ table had primary key of _id_ then, user can issue a query like <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">OData allows for querying navigations from one entity to another.  A navigation is similar to the foreign key relationships in relational databases. For example, if the _customers_ table has an association with the _orders_ table on the _customers_ primary key _id_, then an OData GET could be issued like: <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">this would be akin to, making a JDBC/ODBC connection and issuing a SQL call as <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">this would be akin to making a JDBC/ODBC connection and issuing the SQL: <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code:lang=SQL} <br></td></tr>
            <tr><td class="diff-changed-lines" >SELECT <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">*</span> <span class="diff-added-words"style="background-color: #dfd;">o.*</span> FROM NW.orders o join NW.customers c join o.customer_id = c.id where c.id=1234 and o.orderdate &gt; {ts &#39;2012-12-31 21:23:38&#39;} <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br>{tip:title=More Comprehensive Documentation about ODATA} <br></td></tr>
            <tr><td class="diff-changed-lines" >For detailed protocol access you can read the specification at [http://odata.org]. You can also read this very useful web resource [for an example|http://msdn.microsoft.com/en-us/library/ff478141.aspx] <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">access</span> of <span class="diff-added-words"style="background-color: #dfd;">accessing</span> an OData server. <br></td></tr>
            <tr><td class="diff-unchanged" >{tip} <br> <br>h3. How to update your data? <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Using OData protocol user can issue CREATE/UPDATE/DELETE operations along with READ operations as shown above. These operations use different HTTP methods to accomplish this <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Using the OData protocol it is possible to perform CREATE/UPDATE/DELETE operations along with READ operations shown above. These operations use different HTTP methods. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">INSERT/CREATE is accomplished through HTTP method &quot;POST&quot;, below is an example request. <br>{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">INSERT/CREATE is accomplished through an HTTP method &quot;POST&quot;. <br>{code:title=Example POST} <br></td></tr>
            <tr><td class="diff-unchanged" >POST /service.svc/Customers HTTP/1.1 <br>Host: host <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">To do a UPDATE, HTTP &quot;PUT&quot; method is used, a sample request to update Customer looks like <br>{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">An UPDATE is performed with an HTTP &quot;PUT&quot;. <br>{code:title=Example PUT Update of Customer} <br></td></tr>
            <tr><td class="diff-unchanged" >PUT /service.svc/Customers(&#39;ALFKI&#39;) HTTP/1.1 <br>Host: host <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">For DELETE operation use HTTP &quot;DELETE&quot; method, a sample request looks like <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The DELETE operation uses the HTTP &quot;DELETE&quot; method. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code:title=Example Delete} <br></td></tr>
            <tr><td class="diff-unchanged" >DELETE /service.svc/Customers(&#39;ALFKI&#39;) HTTP/1.1 <br>Host: host <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h3. Security <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Currently by</span> <span class="diff-added-words"style="background-color: #dfd;">By</span> default OData access is secured using HTTPBasic authentication.  The user will be authenticated against Teiid&#39;s default security domain <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">&quot;teiid-security&quot; and makes use of</span> <span class="diff-added-words"style="background-color: #dfd;">&quot;teiid-security&quot;.  Users are expected to have</span> the <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">security role </span>*odata*<span class="diff-added-chars"style="background-color: #dfd;"> role</span>.</span> However, if you wish to change the security domain, manually edit the _web.xml_ file WAR file in _&lt;modules&gt;/org/jboss/teiid/main/deployments_ directory. In future versions more WS-Security based configurations will be provided. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{tip:title=SAML Based Security} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="ODataSupport-WhatisOData"></a>What is OData</h2>

<p>The Open Data Protocol (OData) is a Web protocol for querying and updating data that provides a way to unlock your data and free it from silos that exist in applications today. OData does this by applying and building upon Web technologies such as HTTP, Atom Publishing Protocol (AtomPub) and JSON to provide access to information from a variety of applications, services, and stores. The protocol emerged from experiences implementing AtomPub clients and servers in a variety of products over the past several years.  OData is used to expose and access information from a variety of sources including, but not limited to, relational databases, file systems, content management systems and traditional Web sites.</p>

<p>OData is consistent with the way the Web works - it makes a deep commitment to URIs for resource identification and commits to an HTTP-based, uniform interface for interacting with those resources (just like the Web).  This commitment to core Web principles allows OData to enable a new level of data integration and interoperability across a broad range of clients, servers, services, and tools.</p>

<p>copied from <a href="http://odata.org" class="external-link" rel="nofollow">http://odata.org</a></p>

<h2><a name="ODataSupport-TeiidSupportforOData"></a>Teiid Support for OData</h2>

<p>When a user successfully deploys a VDB into a Teiid Server, the OData protocol support is implicitly provided by the Teiid server without any further configuration. OData support is currently not available in the Teiid Embedded profile. Teiid makes use of JBoss AS and its already configured <a href="http://www.jboss.org/resteasy" class="external-link" rel="nofollow">RestEasy</a> and <a href="http://code.google.com/p/odata4j" class="external-link" rel="nofollow">OData4J</a> libraries to provide Rest based access to the VDB. The access would be similar to accessing to any web resources deployed on JBoss AS. OData support is implemented and deployed through a single WAR file across the Teiid system.  A user can access this WAR file at &lt;jboss-as&gt;/modules/org/jboss/teiid/deployments/odata&#45;8.12.0.Final.war.</p>

<h3><a name="ODataSupport-HowtoAccessthedata%3F"></a>How to Access the data?</h3>

<p>For example, if you have a vdb by name <em>northwind</em> deployed that has a <em>customers</em> table in a <em>NW</em> model, then you can access that table with an HTTP GET via the URL:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
http://localhost:8080/odata/northwind.1/NW.customers
</pre>
</div></div>

<p>this would be akin to making a JDBC/ODBC connection and issuing the SQL:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
SELECT * FROM NW.customers
</pre>
</div></div>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Note that you should fully qualify the table name along with the model name. Also, use correct case (upper or lower) as used in the VDB.</td></tr></table></div>

<p>the returned results from OData query can be in Atom/AtomPub XML or JSON format. AtomPub XML results are returned by default.</p>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Seeing "EdmEntitySet Not Found" error?</b><br /><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: xml; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
When you issue the above query are you seeing a message similar to below?
&lt;error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&gt;
&lt;code&gt;NotFoundException&lt;/code&gt;
&lt;message lang="en-US"&gt;EdmEntitySet NW.customer is not found&lt;/message&gt;
&lt;/error&gt;
</pre>
</div></div>
<p>Then, it means that either you supplied the model-name.table-name combination wrong, check spelling and case. Or your table did not have any PRIMARY KEY or UNIQUE KEY(s) on them. Since OData access is more key oriented, it is * MANDATORY&#42; that every table Teiid exposes through OData must have a PK or at least one UNIQUE key. Note that Teiid does support composite PRIMARY KEYs.</p></td></tr></table></div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Not seeing all the rows?</b><br />See the configuration section below for more details. Issue another call with the same URL, but with the $skiptoken query option specified from the previous result:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
http://localhost:8080/odata/northwind.1/NW.customers?$skiptoken=xxx
</pre>
</div></div></td></tr></table></div>

<p>Users can submit criteria with along their query to filter the results:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
http://localhost:8080/odata/northwind.1/NW.customers?$filter=name eq 'bob'
</pre>
</div></div>

<p>this would be similar to making a JDBC/ODBC connection and issuing the SQL</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
SELECT * FROM NW.customers where name = 'bob'
</pre>
</div></div>

<p>To request the result to be formatted in JSON, add the query option $format=json</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
http://localhost:8080/odata/northwind.1/NW.customers?$format=JSON
</pre>
</div></div>

<p>Query options can be combined as needed.  For example format with a filter:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
http://localhost:8080/odata/northwind.1/NW.customers?$filter=name eq 'bob'&amp;$format=JSON
</pre>
</div></div>

<p>OData allows for querying navigations from one entity to another.  A navigation is similar to the foreign key relationships in relational databases. For example, if the <em>customers</em> table has an association with the <em>orders</em> table on the <em>customers</em> primary key <em>id</em>, then an OData GET could be issued like:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
http://localhost:8080/odata/northwind.1/NW.customers(1234)/NW.orders?$filter=orderdate gt datetime'2012-12-31T21:23:38Z'
</pre>
</div></div>

<p>this would be akin to making a JDBC/ODBC connection and issuing the SQL:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
SELECT o.* FROM NW.orders o join NW.customers c join o.customer_id = c.id where c.id=1234 and o.orderdate &gt; {ts '2012-12-31 21:23:38'}
</pre>
</div></div>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>More Comprehensive Documentation about ODATA</b><br />For detailed protocol access you can read the specification at <a href="http://odata.org" class="external-link" rel="nofollow">http://odata.org</a>. You can also read this very useful web resource <a href="http://msdn.microsoft.com/en-us/library/ff478141.aspx" class="external-link" rel="nofollow">for an example</a> of accessing an OData server.</td></tr></table></div>

<h3><a name="ODataSupport-Howtoupdateyourdata%3F"></a>How to update your data?</h3>
<p>Using the OData protocol it is possible to perform CREATE/UPDATE/DELETE operations along with READ operations shown above. These operations use different HTTP methods.</p>

<p>INSERT/CREATE is accomplished through an HTTP method "POST".</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Example POST</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
POST /service.svc/Customers HTTP/1.1
Host: host
Content-Type: application/atom+xml
Accept: application/atom+xml
Content-Length: nnn
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;entry xml:base="http://host/service.svc/"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://www.w3.org/2005/Atom"&gt;
    &lt;id&gt;http://host/service.svc/Customers('ASDFG')&lt;/id&gt;
    &lt;title type="text" /&gt;
    &lt;updated&gt;2008-12-07T8:00:00Z&lt;/updated&gt;
    &lt;author&gt;
        &lt;name /&gt;
    &lt;/author&gt;
    &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" href="Orders(1)" /&gt;
    &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" href="Orders(2)" /&gt;
    &lt;content type="application/xml"&gt;
        &lt;m:properties&gt;
            &lt;d:CustomerID&gt;ASDFG&lt;/d:CustomerID&gt;
            &lt;d:CompanyName&gt;Contoso Widgets&lt;/d:CompanyName&gt;
            &lt;d:Address&gt;
                &lt;d:Street&gt;58 Contoso St&lt;/d:Street&gt;
                &lt;d:City&gt;Seattle&lt;/d:City&gt;
            &lt;/d:Address&gt;
        &lt;/m:properties&gt;
    &lt;/content&gt;
&lt;/entry&gt;
</pre>
</div></div>

<p>An UPDATE is performed with an HTTP "PUT".</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Example PUT Update of Customer</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
PUT /service.svc/Customers('ALFKI') HTTP/1.1
Host: host
Content-Type: application/atom+xml
Accept: application/atom+xml
Content-Length: nnn
DataServiceVersion: 1.0
MaxDataServiceVersion: 3.0
Prefer: return-content
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"&gt;
    &lt;content type="application/xml"&gt;
    &lt;m:properties&gt;
        &lt;d:CustomerID&gt;ALFKI&lt;/d:CustomerID&gt;
        &lt;d:CompanyName&gt;Updated Company Name&lt;/d:CompanyName&gt;
        &lt;d:Address&gt;
        &lt;d:Street&gt;Updated Street&lt;/d:Street&gt;
        &lt;/d:Address&gt;
    &lt;/m:properties&gt;
    &lt;/content&gt;
&lt;/entry&gt;
</pre>
</div></div>

<p>The DELETE operation uses the HTTP "DELETE" method.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Example Delete</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
DELETE /service.svc/Customers('ALFKI') HTTP/1.1
Host: host
Content-Type: application/atom+xml
Accept: application/atom+xml
Content-Length: nnn
DataServiceVersion: 1.0
</pre>
</div></div>


<h3><a name="ODataSupport-Security"></a>Security</h3>

<p>By default OData access is secured using HTTPBasic authentication.  The user will be authenticated against Teiid's default security domain "teiid-security".  Users are expected to have the <b>odata</b> role. However, if you wish to change the security domain, manually edit the <em>web.xml</em> file WAR file in <em>&lt;modules&gt;/org/jboss/teiid/main/deployments</em> directory. In future versions more WS-Security based configurations will be provided.</p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>SAML Based Security</b><br />To provide Single-Sign-On (SSO) using SAML2 for OData access, please take a look in the <a href="/author/display/TEIID/Security+Guide" title="Security Guide">Security Guide</a> for <a href="/author/display/TEIID/SAML+Based+Security+For+OData" title="SAML Based Security For OData">SAML Based Security For OData</a> section.</td></tr></table></div>

<h3><a name="ODataSupport-Configuration"></a>Configuration</h3>

<p>The OData WAR file can be configured with following properties in the web.xml file.</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property Name </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Default Value </th>
</tr>
<tr>
<td class='confluenceTd'> batch-size </td>
<td class='confluenceTd'> Number of rows to send back each time, &#45;1 returns all rows </td>
<td class='confluenceTd'> 256 </td>
</tr>
<tr>
<td class='confluenceTd'> skiptoken-cache-time </td>
<td class='confluenceTd'> Time interval between the results being recycled/expired between $skiptoken requests </td>
<td class='confluenceTd'> 300000 </td>
</tr>
<tr>
<td class='confluenceTd'> local-transport-name </td>
<td class='confluenceTd'> Teiid Local transport name for connection </td>
<td class='confluenceTd'> odata </td>
</tr>
<tr>
<td class='confluenceTd'> invalid-xml10-character-replacement </td>
<td class='confluenceTd'> Replacement string if an invalid XML 1.0 character appears in the data - note that this replacement will occur even if JSON is requested. <br/>
No value (the default) means that an exception will be thrown with XML results if such a character is encountered. </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'>proxy-base-uri</td>
<td class='confluenceTd'>Defines the proxy server's URI to be used in OData responses.</td>
<td class='confluenceTd'>n/a</td>
</tr>
<tr>
<td class='confluenceTd'>connection.XXX</td>
<td class='confluenceTd'>Sets XXX as an execution property on the local connection.  Can be used for example to enable result set cache mode.</td>
<td class='confluenceTd'>n/a</td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>"Behind Proxy or In Cloud Environments?"</b><br />If the Teiid server is configured behind a proxy server or deployed in cloud environment, or using a load-balancer then the URI of the server which is handling the OData request is different from URI of proxy. To generate valid links in the OData responses configure "proxy-base-uri" property in the web.xml. If this value is available as system property then define the property value like below
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
    &lt;context-param&gt;
        &lt;param-name&gt;proxy-base-uri&lt;/param-name&gt;
        &lt;param-value&gt;${system-property-name}&lt;/param-value&gt;
    &lt;/context-param&gt;  
</pre>
</div></div></td></tr></table></div>

<p>Teiid OData server, implements cursoring logic when the result rows exceed the configured batch size. On every request, only <em>batch-size</em> number of rows are returned. Each such request is considered an active cursor, with a specified amount of idle time specified by <em>skip-token-cache-time</em>. After the cursor is timed out, the cursor will be closed and remaining results will be cleaned up, and will no longer be available for further queries. Since there is no session based tracking of these cursors, if the request for skiptoken comes after the expired time, the original query will be executed again and tries to reposition the cursor to relative absolute potion, however the results are not guaranteed to be same as the underlying sources may have been updated with new information meanwhile.</p>

<h3><a name="ODataSupport-Limitations"></a>Limitations</h3>

<p>The following feature limitations currently apply.</p>

<ul>
        <li>Teiid implements the OData V2 specification along with many V3 features, however OData V3 is not completely supported.</li>
        <li>Blob support for media types are not supported.</li>
        <li>"$value" construct to retrieve individual column value is not supported.</li>
        <li>create/update/delete $links is not supported.</li>
        <li>$expand is not supported.</li>
</ul>


<h2><a name="ODataSupport-ClientToolsforAccess"></a>Client Tools for Access</h2>

<p>OData access is really where the user comes in, depending upon your programming model and needs there are various ways you write your access layer into OData. The following are some suggestions:</p>

<ul>
        <li>Your Browser: The OData Explorer is an online tool for browsing an OData data service.</li>
        <li>Microsoft .NET Framework 3.51: the WCF Data Services framework is available as a separate download for .NET 3.x.</li>
        <li>Microsoft .NET Framework 4.0: the WCF Data Services framework built into .NET 4.0 (in release candidate as of this writing).</li>
        <li>Silverlight 3: the Data Services client library for Silverlight is available for download.</li>
        <li>Java: the Restlet 2.0 library for Java (including Java on your Android phone) supports the OData protocol.</li>
        <li>Java: Use a library like OData4J for Java based access, or any Rest based framework</li>
        <li>JavaScript: the XMLHttpRequest object is standard in modern browsers or you can use jQuery, which comes out of the box with .NET 4.0 or is available for download.</li>
        <li>PHP: the Toolkit for PHPprovides OData support for PHP clients.</li>
        <li>AJAX: if you're using AJAX for ASP.NET, Microsoft provides the ASP.NET Ajax Library for getting to OData.</li>
        <li>Excel 2010 PowerPivot: PowerPivot comes with OData support built right in.</li>
        <li>Windows Desktop: LINQPad is a wonderful tool for building OData queries interactively.</li>
        <li>Shell Scripts: use CURL tool</li>
</ul>


<h2><a name="ODataSupport-HowTeiidexposesschemaforOData"></a>How Teiid exposes schema for OData</h2>

<p>OData defines its schema using Conceptual Schema Definition Language (CSDL). Every VDB, that is deployed in an ACTIVE state in Teiid server exposes its metadata in CSDL format. For example if you want retrieve metadata for your vdb <em>northwind</em>, you need to issue a query like</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
http://localhost:8080/odata/northwind/$metadata
</pre>
</div></div>

<p>Since OData schema model is not a relational schema model, Teiid uses the following semantics to map its relational schema model to OData schema model.</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Relational Entity </th>
<th class='confluenceTh'> Mapped OData Entity </th>
</tr>
<tr>
<td class='confluenceTd'> Model Name </td>
<td class='confluenceTd'> Schema Namespace, EntityContainer Name </td>
</tr>
<tr>
<td class='confluenceTd'> Table/View </td>
<td class='confluenceTd'> EntityType, EntitySet </td>
</tr>
<tr>
<td class='confluenceTd'> Table Columns </td>
<td class='confluenceTd'> EntityType's Properties </td>
</tr>
<tr>
<td class='confluenceTd'> Primary Key </td>
<td class='confluenceTd'> EntityType's Key Properties </td>
</tr>
<tr>
<td class='confluenceTd'> Foreign Key </td>
<td class='confluenceTd'> Navigation Property on EntityType, Association, AssosiationSet </td>
</tr>
<tr>
<td class='confluenceTd'> Procedure </td>
<td class='confluenceTd'> FunctionImport </td>
</tr>
<tr>
<td class='confluenceTd'> Procedure's Table Return </td>
<td class='confluenceTd'> ComplexType </td>
</tr>
</tbody></table>
</div>


<p>Teiid by design does not define any "embedded" ComplexType in the EntityType.</p>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Teiid does not define any one EntityContainer that resulted from different vdb models as a default container, so all entities must be accessed using full path to them.</td></tr></table></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://docs.jboss.org/author/display/TEIID/OData+Support">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=59146740&revisedVersion=19&originalVersion=18">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/OData+Support?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>