Protocollo Open Data

In informatica, Il Protocollo Open Data (in inglese: Open Data Protocol) o OData è un protocollo aperto che permette la creazione e il consumo di API RESTful interoperabili e interrogabili in maniera semplice e standard. Microsoft creò gli OData nel 2007. Le versioni 1.0, 2.0 e 3.0 sono state rilasciate sotto la licenza Microsoft Open Specification Promise. La versione 4.0 fu standardizzata presso l'OASIS nel marzo 2014. Nell'aprile 2015 OASIS propone gli Odata versione 4 e il formato OData JSON versione 4 all'ISO/IEC JTC 1 per un'approvazione come standard internazionale. Il 23 febbraio 2017 ISO/IEC JTC 1 approva lo standard OData (ISO/IEC 20802-1:2016 [1] e ISO/IEC 20802-2:2016 [2]) per lo scambio degli Open Data [3].

Rappresentazione delle risorse[modifica | modifica wikitesto]

Esempio di payload OData JSON[modifica | modifica wikitesto]

A collection of products:

{   "@odata.context": "http://services.odata.org/V4/OData/OData.svc/$metadata#Products",   "value": [     {       "ID": 0,       "Name": "Bread",       "Description": "Whole grain bread",       "ReleaseDate": "1992-01-01T00:00:00Z",       "DiscontinuedDate": null,       "Rating": 4,       "Price": 2.5     },     {       "ID": 1,       "Name": "Milk",       "Description": "Low fat milk",       "ReleaseDate": "1995-10-01T00:00:00Z",       "DiscontinuedDate": null,       "Rating": 3,       "Price": 3.5     },     ...   ] } 

Un esempio di payload OData Atom[modifica | modifica wikitesto]

A collection of products:

<feed xml:base="http://services.odata.org/V4/OData/OData.svc/" m:context="http://services.odata.org/V4/OData/OData.svc/$metadata#Products" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">   <id>http://services.odata.org/v4/odata/odata.svc/Products</id>   <title type="text">Products</title>   <updated>2015-05-19T03:38:50Z</updated>   <link rel="self" title="Products" href="Products"/>   <entry>     <id>http://services.odata.org/V4/OData/OData.svc/Products(0)</id>     <category term="#ODataDemo.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>     <link rel="edit" title="Product" href="Products(0)"/>     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Categories" type="application/xml" title="Categories" href="Products(0)/Categories/$ref"/>     <link rel="http://docs.oasis-open.org/odata/ns/related/Categories" type="application/atom+xml;type=feed" title="Categories" href="Products(0)/Categories"/>     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier" type="application/xml" title="Supplier" href="Products(0)/Supplier/$ref"/>     <link rel="http://docs.oasis-open.org/odata/ns/related/Supplier" type="application/atom+xml;type=entry" title="Supplier" href="Products(0)/Supplier"/>     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail" type="application/xml" title="ProductDetail" href="Products(0)/ProductDetail/$ref"/>     <link rel="http://docs.oasis-open.org/odata/ns/related/ProductDetail" type="application/atom+xml;type=entry" title="ProductDetail" href="Products(0)/ProductDetail"/>     <title/>     <updated>2015-05-19T03:38:50Z</updated>     <author>       <name/>     </author>     <content type="application/xml">       <m:properties>         <d:ID m:type="Int32">0</d:ID>         <d:Name>Bread</d:Name>         <d:Description>Whole grain bread</d:Description>         <d:ReleaseDate m:type="DateTimeOffset">1992-01-01T00:00:00Z</d:ReleaseDate>         <d:DiscontinuedDate m:null="true"/>         <d:Rating m:type="Int16">4</d:Rating>         <d:Price m:type="Double">2.5</d:Price>       </m:properties>     </content>   </entry>   <entry>     <id>http://services.odata.org/V4/OData/OData.svc/Products(1)</id>     <category term="#ODataDemo.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>     <link rel="edit" title="Product" href="Products(1)"/>     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Categories" type="application/xml" title="Categories" href="Products(1)/Categories/$ref"/>     <link rel="http://docs.oasis-open.org/odata/ns/related/Categories" type="application/atom+xml;type=feed" title="Categories" href="Products(1)/Categories"/>     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier" type="application/xml" title="Supplier" href="Products(1)/Supplier/$ref"/>     <link rel="http://docs.oasis-open.org/odata/ns/related/Supplier" type="application/atom+xml;type=entry" title="Supplier" href="Products(1)/Supplier"/>     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail" type="application/xml" title="ProductDetail" href="Products(1)/ProductDetail/$ref"/>     <link rel="http://docs.oasis-open.org/odata/ns/related/ProductDetail" type="application/atom+xml;type=entry" title="ProductDetail" href="Products(1)/ProductDetail"/>     <title/>     <updated>2015-05-19T03:38:50Z</updated>     <author>       <name/>     </author>     <content type="application/xml">       <m:properties>         <d:ID m:type="Int32">1</d:ID>         <d:Name>Milk</d:Name>         <d:Description>Low fat milk</d:Description>         <d:ReleaseDate m:type="DateTimeOffset">1995-10-01T00:00:00Z</d:ReleaseDate>         <d:DiscontinuedDate m:null="true"/>         <d:Rating m:type="Int16">3</d:Rating>         <d:Price m:type="Double">3.5</d:Price>       </m:properties>     </content>   </entry>   ... </feed> 

Un esempio di documento metadato OData[modifica | modifica wikitesto]

<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">   <edmx:DataServices>     <Schema Namespace="ODataDemo" xmlns="http://docs.oasis-open.org/odata/ns/edm">       <EntityType Name="Product">         <Key>           <PropertyRef Name="ID"/>         </Key>         <Property Name="ID" Type="Edm.Int32" Nullable="false"/>         <Property Name="Name" Type="Edm.String"/>         <Property Name="Description" Type="Edm.String"/>         <Property Name="ReleaseDate" Type="Edm.DateTimeOffset" Nullable="false"/>         <Property Name="DiscontinuedDate" Type="Edm.DateTimeOffset"/>         <Property Name="Rating" Type="Edm.Int16" Nullable="false"/>         <Property Name="Price" Type="Edm.Double" Nullable="false"/>       </EntityType>        <ComplexType Name="Address">         <Property Name="Street" Type="Edm.String"/>         <Property Name="City" Type="Edm.String"/>         <Property Name="State" Type="Edm.String"/>         <Property Name="ZipCode" Type="Edm.String"/>         <Property Name="Country" Type="Edm.String"/>       </ComplexType>              <EntityContainer Name="DemoService">         <EntitySet Name="Products" EntityType="ODataDemo.Product"></EntitySet>       </EntityContainer>     </Schema>   </edmx:DataServices> </edmx:Edmx> 

Note[modifica | modifica wikitesto]

  1. ^ ISO/IEC 20802-1:2016 - Open data protocol (OData) v4.0 - Part 1: Core, su iso.org. URL consultato il 23 luglio 2017.
  2. ^ ISO/IEC 20802-2:2016 - Open data protocol (OData) v4.0 -- Part 2: OData JSON Format, su iso.org. URL consultato il 23 luglio 2017.
  3. ^ OISO/IEC JTC 1 Approves OASIS OData Standard for Open Data Exchange, su oasis-open.org. URL consultato il 23 luglio 2017.

Voci correlate[modifica | modifica wikitesto]

Collegamenti esterni[modifica | modifica wikitesto]

Standard OData OASIS[modifica | modifica wikitesto]