This HTML5 document contains 58 embedded RDF statements represented using HTML+Microdata notation.

The embedded RDF content will be recognized by any processor of HTML5 Microdata.

PrefixNamespace IRI
n31http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/EntityDetails.
n23http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/DataModel.
n14http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/AddModel.
n34http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/ODataServiceExample/sioc.
n7http://en.wikipedia.org/wiki/
n29http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/ODataExplorer.
n15http://rdfs.org/sioc/services#
n36http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/TestService.
dchttp://purl.org/dc/elements/1.1/
n18http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/ConnProps2.
n4http://vos.openlinksw.com/dataspace/owiki#
n9http://www.odata.org/
n30http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/EdmWizard4.
n2http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/
n28http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/NewProject.
dctermshttp://purl.org/dc/terms/
n16http://vos.openlinksw.com/dataspace/services/wiki/
rdfshttp://www.w3.org/2000/01/rdf-schema#
rdfhttp://www.w3.org/1999/02/22-rdf-syntax-ns#
n6http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/AddNewService.
n21http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/EdmWizard2.
atomhttp://atomowl.org/ontologies/atomrdf#
n8http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/AddNewService2.
n27http://vos.openlinksw.com/dataspace/dav#
xsdhhttp://www.w3.org/2001/XMLSchema#
n41http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/ViewCollection.
siochttp://rdfs.org/sioc/ns#
n40http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/UpdatedData.
n43http://vos.openlinksw.com/dataspace/person/owiki#
n17http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/ConnProps.
n38http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/OriginalData.
n45http://msdn.microsoft.com/en-us/library/dd831853.
n10http://tools.ietf.org/html/
n35http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/SingleRecord.
oplhttp://www.openlinksw.com/schema/attribution#
n25http://vos.openlinksw.com/dataspace/person/dav#
n20http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/ChooseDatabase.
n24http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/EdmWizard.
n5http://silverlight.net/content/samples/odataexplorer/
n37http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/ODataWebAppProject.
n22http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/EdmWizard3.
foafhttp://xmlns.com/foaf/0.1/
n19http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/ChangeDataSource.
n39http://vos.openlinksw.com/wiki/main/VOS/ODataServiceExample/VirtuosoServiceUri.
siocthttp://rdfs.org/sioc/types#
n13http://vos.openlinksw.com/dataspace/owiki/wiki/
Subject Item
n25:this
foaf:made
n2:ODataServiceExample
Subject Item
n27:this
sioc:creator_of
n2:ODataServiceExample
Subject Item
n16:item
n15:services_of
n2:ODataServiceExample
Subject Item
n4:this
sioc:creator_of
n2:ODataServiceExample
Subject Item
n13:VOS
sioc:container_of
n2:ODataServiceExample
atom:entry
n2:ODataServiceExample
atom:contains
n2:ODataServiceExample
Subject Item
n2:VirtAdoNet35Provider
sioc:links_to
n2:ODataServiceExample
Subject Item
n2:ODataServiceExample
rdf:type
sioct:Comment atom:Entry
dcterms:created
2017-06-13T05:41:42.437236
dcterms:modified
2017-06-29T07:34:52.176441
rdfs:label
ODataServiceExample
foaf:maker
n25:this n43:this
dc:title
ODataServiceExample
opl:isDescribedUsing
n34:rdf
sioc:has_creator
n4:this n27:this
sioc:attachment
n6:png n8:png n14:png n17:png n18:png n19:png n20:png n21:png n22:png n23:png n24:png n28:png n29:png n30:png n31:png n35:png n36:png n37:png n38:png n39:png n40:png n41:png
sioc:content
%META:TOPICPARENT{name="VirtAdoNet35Provider"}% ---+Creating an OData Publishing Endpoint using Virtuoso's ADO.NET Data Provider %TOC% ---++ Introduction ---+++ What is OData? [[http://www.odata.org/][OData]] is an HTTP-based data protocol, with associated data representation formats (Atom and JSON). The underlying data model takes the form of an Entity-Attribute-Value graph, and originates from the Entity Frameworks aspect of ADO.NET. In this model, individual entities, entity attributes, and (optionally) attribute values are identified by Uniform Resource Identifiers (URIs). In short, OData decouples wire protocol data access and data representation formats from the ADO.NET platform. The simplest service consists of a single feed hosting a basic Entity-Attribute-Value model tuple represented in Atom or JSON. Typically a service will provide a number of feeds, listed in the top-level service document. The model is published at the top level as a service-specific metadata document. ---+++ Why is OData Important? The Open Data Protocol (OData) is a protocol for sharing data. Producers expose data as an OData service at an HTTP location (i.e., a URL) which is then available to OData consumers. As the OData protocol is based on the [[http://tools.ietf.org/html/rfc5023][AtomPub]] standard, the simplest consumer can take the form of any HTTP user agent (e.g., a Web Browser), which is then able to browse entity-attribute-value model data stored within the Atom feeds. Likewise, Rich Internet Application clients, launched from within browsers or as stand-alone applications, such as the [[http://silverlight.net/content/samples/odataexplorer/][Silverlight OData Explorer]], may be used to browse this data. Either way, data from a range of disparate sources can be exposed as HTTP-accessible structured hypermedia resources (delivered by the Atom Feed). By cleanly separating client and server roles, OData can serve as an HTTP analog of the platform-specific [[http://en.wikipedia.org/wiki/Open_Database_Connectivity][ODBC]] (version 2.0, as of this writing). As with ODBC, data consuming applications can be developed independently from data sources, and a single application can consume data from a range of disparate sources. The OData service endpoint can be specified at runtime just as an ODBC Data Source Name (DSN) would be. ---+++ How are Virtuoso and OData Connected? Virtuoso is a hybrid data server with native data management and integration capabilities covering RDF via SPARQL, ODBC or JDBC accessible Relational Data Sources; XML via XQuery/XPath; Web Services; and other HTTP-accessible Hypermedia and non-Hypermedia resources. Virtuoso includes a high-performance native ADO.NET data provider that provides access to its Relational-, RDF Graph-, and Document-model based storage engines, and thereby also makes data from these engines accessible to OData-based data consumers. ---++ How Do I use Virtuoso to Publish OData ? There are two ways to produce OData from Virtuoso: one approach uses Virtuoso's built-in support of the lightweight and platform-agnostic OData protocol; the other uses Virtuoso's ADO.NET provider. This guide covers use of the ADO.NET provider. To create an OData service endpoint using Virtuoso and its ADO.NET provider, you will need the following in place: * Microsoft Visual Studio 2010 * The ADO.NET Entity Framework 4.0 runtime and associated tools (included in Visual Studio 2010, but not installed by default) At the start of your Visual Studio project creation, you must establish a connection with the database(s) hosting the data to be exposed by the service. Once a connection has been established, you can generate a data model which lays the foundation for publishing an OData service. The following steps show how to expose the Northwind Demo database in Virtuoso as an OData Service using the Virtuoso ADO.NET Provider: 1 Launch the <b>Visual Studio 2010 IDE</b>. 1 Choose <b>New Project</b> from the <b>File</b> menu to create a <b>Web Application</b> project. 1 When the <b>New Project</b> window appears, choose either <b>Visual Basic</b> or <b>Visual C#</b> as the programming language. 1 Within the language category, click on <b>Web</b>, and select <b>ASP.NET Web Application</b> from the right-hand panel. %BR%%BR%<a href="%ATTACHURLPATH%/NewProject.png"><img src="%ATTACHURLPATH%/NewProject.png" alt="NewProject.png" /></a>%BR%%BR% 1 Choose a name for the project, for example <code><nowiki>ODataWebApplication</nowiki></code>, and click OK. 1 This will create a new project called <nowiki>OdataWebApplication</nowiki>. %BR%%BR%<a href="%ATTACHURLPATH%/ODataWebAppProject.png"><img src="%ATTACHURLPATH%/ODataWebAppProject.png" /></a>%BR%%BR% 1 To set up the database connection and generate the data model, right click on the <nowiki>OdataWebApplication</nowiki> project name in the <b>Solution Explorer</b> pane; then select the <b>Add -> New Item</b> menu item. 1 The <b>Add New Item</b> dialog will appear. Choose <b>Data</b> from the <b>Installed Templates</b>; then select the <b>ADO.NET Entity Data Model</b> template from the right-hand pane. Name the model <b><code>DemoModel.edmx</code></b>, and click <b>Add</b> to start the creation of the ADO.NET Entity Data Model. %BR%%BR%<a href="%ATTACHURLPATH%/AddModel.png"><img src="%ATTACHURLPATH%/AddModel.png" alt="AddModel.png" /></a>%BR%%BR% 1 In the <b>Entity Data Model Wizard</b> dialog's <b>Choose Model Contents</b> pane, select the <b>Generate from Database</b> model type and click <b>Next</b>. %BR%%BR%<a href="%ATTACHURLPATH%/EdmWizard.png"><img src="%ATTACHURLPATH%/EdmWizard.png" alt="EdmWizard.png" /></a>%BR%%BR% 1 In the <b>Entity Data Model Wizard</b> dialog's <b>Choose your Data Connection</b> pane, select the <b>New Connection</b> button. %BR%%BR%<a href="%ATTACHURLPATH%/EdmWizard2.png"><img src="%ATTACHURLPATH%/EdmWizard2.png" alt="EdmWizard2.png" /></a>%BR%%BR% 1 In the <b>Choose Data Source</b> dialog, select the <b>OpenLink Virtuoso Data Source</b> from the list displayed and click <b>Continue</b>. %BR%%BR%<a href="%ATTACHURLPATH%/ChangeDataSource.png"><img src="%ATTACHURLPATH%/ChangeDataSource.png" alt="ChangeDataSource.png" /></a>%BR%%BR% 1 In the <b>Add Connection</b> dialog, specify the <b>hostname</b>, <b>port number</b>, <b>username</b>, and <b>password</b> for the target Virtuoso Server and check the <b>Save Password</b> box. %BR%%BR%<a href="%ATTACHURLPATH%/ConnProps2.png"><img src="%ATTACHURLPATH%/ConnProps2.png" alt="ConnProps2.png" /></a>%BR%%BR% 1 Select the <b>Select Database From List</b> radio button and choose <b>Demo</b> from the drop down list, assuming the <b>Virtuoso Demo Database</b> is installed. %BR%%BR%<a href="%ATTACHURLPATH%/ChooseDatabase.png"><img src="%ATTACHURLPATH%/ChooseDatabase.png" alt="ChooseDatabase.png" /></a>%BR%%BR% 1 Click the <b>Test Connection</b> button to verify the connection is successful and then click <b>OK</b> to add the connection. 1 Set the entity connect string name to <b><nowiki><code>VirtuosoDemoEntities</code></nowiki></b> (remember the name you set here, as it is required in step 20 below) and click <b>Next</b>. %BR%%BR%<a href="%ATTACHURLPATH%/EdmWizard3.png"><img src="%ATTACHURLPATH%/EdmWizard3.png" alt="EdmWizard3.png" /></a>%BR%%BR% 1 In the <b>Choose your Database Objects</b> pane, tick the <b>Tables</b> check-box to select all tables in the Demo database for addition to the Entity Data Model, set the Model Namespace to <b><nowiki>VirtuosoDemoModel</nowiki></b>, and click <b>Finish</b>. %BR%%BR%<a href="%ATTACHURLPATH%/EdmWizard4.png"><img src="%ATTACHURLPATH%/EdmWizard4.png" alt="EdmWizard4.png" /></a>%BR%%BR% 1 The <b><nowiki>VirtuosoDemoModel.edmx</nowiki></b> EDM will be created, with the tables and relationships displayed in the Visual Studio IDE. %BR%%BR%<a href="%ATTACHURLPATH%/DataModel.png"><img src="%ATTACHURLPATH%/DataModel.png" alt="DataModel.png" /></a>%BR%%BR% 1 Now to create the service. Right click on the <b><nowiki>ODataWebApplication</nowiki></b> project name of the Solution Explorer pane, then select the <b>Add -> New Item</b> menu item. 1 The <b>Add New Item</b> dialog will appear. Select <b>Web</b> from the installed templates, and choose the <b>WCF Data Service</b> template in the right-hand pane. Name the service <b><code><nowiki>VirtuosoOData.svc</nowiki></code></b>, and click <b>Add</b> to create the OData Service. %BR%%BR%<a href="%ATTACHURLPATH%/AddNewService2.png"><img src="%ATTACHURLPATH%/AddNewService2.png" alt="AddNewService2.png" /></a>%BR%%BR% 1 In the <b><code><nowiki>VirtuosoOData.svc.cs</nowiki></code></b> Data Service file created by the steps above, add the data source class name of <b><code><nowiki>VirtuosoDemoEntities</nowiki></code></b> (note: this is the name set in step 15, above) as the <nowiki>DataService</nowiki> name, and enable access to the Data Service by adding the entry <b><code><nowiki>config.SetEntitySetAccessRule("*", EntitySetRights.All);</nowiki></code></b> in the <nowiki>InitializeService </nowiki>method. <verbatim> public static void InitializeService(DataServiceConfiguration config) { // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc. // Examples: // config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead); // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All); config.SetEntitySetAccessRule("*", EntitySetRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } </verbatim> 1 To test the OData Service, simply hit <code>Ctrl+F5</code> within Visual Studio, which will start the development web server, run the OData Services server therein, and load a Web browser page displaying the list of available tables/entities of the Demo database. %BR%%BR%<a href="%ATTACHURLPATH%/TestService.png"><img src="%ATTACHURLPATH%/TestService.png" alt="TestService.png" /></a>%BR%%BR% ---++ How do I Consume the Published OData? The simplest way to consume the service is to use a web browser to browse the Atom feed. This is what is done when testing the service in Visual Studio. As well as the top-level list of feeds provided by the service, it is straightforward to access a specific entity instance. For example, to access the <code>ALFKI</code> record of the <code>Customers</code> table, simply append <b><code><nowiki>/Customers('ALFKI')</nowiki></code></b> to the service root URI. %BR%%BR%<a href="%ATTACHURLPATH%/SingleRecord.png"><img src="%ATTACHURLPATH%/SingleRecord.png" alt="SingleRecord.png" /></a>%BR%%BR% Similarly, the metatdata document can examined by appending <code><nowiki>/$metadata</nowiki></code> to the service instance URI. The metadata document is useful for finding information about the entities provided on the service. Alternatively, the service can be consumed by a more sophisticated application like the [[http://silverlight.net/content/samples/odataexplorer/][Silverlight OData Explorer]]. 1 While the OData service is running, open the Silverlight OData Explorer as a stand-alone application on the local machine. 1 Choose a workspace name, and give your data service root URI. %BR%%BR%<a href="%ATTACHURLPATH%/VirtuosoServiceUri.png"><img src="%ATTACHURLPATH%/VirtuosoServiceUri.png" alt="VirtuosoServiceUri.png" /></a>%BR%%BR% 1 The entity types available on your service are listed in the <b>Collections</b> box, and by selecting one, you can see a list of all entities of the chosen type. %BR%%BR%<a href="%ATTACHURLPATH%/ViewCollection.png"><img src="%ATTACHURLPATH%/ViewCollection.png" alt="ViewCollection.png" /></a>%BR%%BR% The Silverlight OData Explorer also allows you to update data via the service. For example: 1 List the <code>Customers</code> entities. %BR%%BR%<a href="%ATTACHURLPATH%/OriginalData.png"><img src="%ATTACHURLPATH%/OriginalData.png" alt="OriginalData.png" /></a>%BR%%BR% 1 Click the <b>Edit</b> button at the left of the record you wish to update. This opens an edit dialog where you can make changes to the attributes of the entity. %BR%%BR%<a href="%ATTACHURLPATH%/EntityDetails.png"><img src="%ATTACHURLPATH%/EntityDetails.png" alt="EntityDetails.png" /></a>%BR%%BR% 1 By clicking <b><nowiki>SaveChanges</nowiki></b>, you propagate your edits back to the underlying data store. If you close the edit box and reload the list of entities, you will see that the record has been updated. %BR%%BR%<a href="%ATTACHURLPATH%/UpdatedData.png"><img src="%ATTACHURLPATH%/UpdatedData.png" alt="UpdatedData.png" /></a>%BR%%BR% ---+++ Notes 1 <b>Important</b> - To view Atom data (the default format returned by an ADO.NET Data Service) in Internet Explorer, you must first ensure that <b>Feed Reading View<b/> is turned off. This can be done on the <b>Content</b> tab of <b>Tools</b> in <b>Internet Options</b>. 1 If a Data Services entity instance URI page fails to load, turn <b>Verbose error</b>s on by adding <b><code><nowiki>config.UseVerboseErrors = true;</nowiki></code></b> to the <code>virtuoso.svc.cs</code> <nowiki>InitializeService</nowiki> method to obtain more detailed information from the server as to why the page failed to load: <verbatim> public static void InitializeService(IDataServiceConfiguration config) { config.UseVerboseErrors = true; config.SetEntitySetAccessRule("*", EntitySetRights.All); } </verbatim> ---++ Related * [[VirtRDFODataExample][Acessing RDF Triples as OData Service]] * [[VirtAdoNet35Provider][Virtuoso ADO.NET 3.5 Provider]] * [[http://www.odata.org/][Open Data Protocol]] * [[http://msdn.microsoft.com/en-us/library/dd831853.aspx][Visual Studio 2010]]
sioc:id
89a036c839885e6b4a7a658aa4f31dc9
sioc:link
n2:ODataServiceExample
sioc:has_container
n13:VOS
n15:has_services
n16:item
atom:title
ODataServiceExample
sioc:links_to
n5: n7:Open_Database_Connectivity n9: n10:rfc5023 n2:OpenLink n45:aspx
atom:source
n13:VOS
atom:author
n25:this
atom:published
2017-06-13T05:41:42Z
atom:updated
2017-06-29T07:34:52Z
sioc:topic
n13:VOS