Deschideți Protocolul de date

De la Wikipedia, enciclopedia liberă.
Salt la navigare Salt la căutare

În informatică , Open Data Protocol (în engleză: Open Data Protocol ) sau OData este un protocol deschis care permite crearea și consumul de API- uri RESTful interoperabile și interogabile într-un mod simplu și standard. Microsoft a creat OData în 2007 . Versiunile 1.0, 2.0 și 3.0 au fost lansate sub licența Microsoft Open Specification Promise . Versiunea 4.0 a fost standardizată la OASIS în martie 2014 . În aprilie 2015, OASIS propune Odata versiunea 4 și OData JSON versiunea 4 format ISO / IEC JTC 1 pentru aprobare ca standard internațional. La 23 februarie 2017 ISO / IEC JTC 1 aprobă standardul OData (ISO / IEC 20802-1: 2016 [1] și ISO / IEC 20802-2: 2016 [2] ) pentru schimbul de date deschise [3] .

Reprezentarea resurselor

Exemplu de încărcare utilă OData JSON

O colecție de produse:

 {
"@ odata.context" : "http://services.odata.org/V4/OData/OData.svc/$metadata#Products" ,
„valoare” : [
{
„ID” : 0 ,
„Nume” : „Pâine” ,
"Descriere" : "Pâine integrală" ,
"ReleaseDate" : "1992-01-01T00: 00: 00Z" ,
"DiscontinuedDate" : nul ,
„Evaluare” : 4 ,
„Preț” : 2,5
},
{
„ID” : 1 ,
„Nume” : „Lapte” ,
"Descriere" : "Lapte cu conținut scăzut de grăsimi" ,
"ReleaseDate" : "1995-10-01T00: 00: 00Z" ,
"DiscontinuedDate" : nul ,
„Evaluare” : 3 ,
„Preț” : 3.5
},
...
]
}

Un exemplu de sarcină utilă OData Atom

O colecție de produse:

 <feed xml: base = "http://services.odata.org/V4/OData/OData.svc/" m: context = "http://services.odata.org/V4/OData/OData.svc/$ metadate # Produse " 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" > Produse </title>
<actualizat> 2015-05-19T03: 38: 50Z </updated>
<link rel = "self" title = "Produse" href = "Produse" />
<intrare>
<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 = "Produs" href = "Produse (0)" />
<link rel = "http://docs.oasis-open.org/odata/ns/relatedlinks/Categories" type = "application / xml" title = "Categorii" href = "Produse (0) / Categorii / $ ref" />
<link rel = "http://docs.oasis-open.org/odata/ns/related/Categories" type = "application / atom + xml; type = feed" title = "Categorii" href = "Produse (0) / Categorii " />
<link rel = "http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier" type = "application / xml" title = "Furnizor" href = "Produse (0) / Furnizor / $ ref" />
<link rel = "http://docs.oasis-open.org/odata/ns/related/Supplier" type = "application / atom + xml; type = entry" title = "Furnizor" href = "Produse (0) / Furnizor " />
<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 " />
<titlu />
<actualizat> 2015-05-19T03: 38: 50Z </updated>
<autor>
<nume />
</author>
<content type = "application / xml" >
<m: proprietăți>
<d: ID m: type = "Int32" > 0 </ d: ID>
<d: Nume> Pâine </ d: Nume>
<d: Descriere> Pâine integrală </ d: Descriere>
<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: Preț m: type = "Double" > 2,5 </ d: Preț>
</ m: proprietăți>
</content>
</entry>
<intrare>
<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 = "Produs" href = "Produse (1)" />
<link rel = "http://docs.oasis-open.org/odata/ns/relatedlinks/Categories" type = "application / xml" title = "Categorii" href = "Produse (1) / Categorii / $ ref" />
<link rel = "http://docs.oasis-open.org/odata/ns/related/Categories" type = "application / atom + xml; type = feed" title = "Categorii" href = "Produse (1) / Categorii " />
<link rel = "http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier" type = "application / xml" title = "Furnizor" href = "Produse (1) / Furnizor / $ ref" />
<link rel = "http://docs.oasis-open.org/odata/ns/related/Supplier" type = "application / atom + xml; type = entry" title = "Furnizor" href = "Produse (1) / Furnizor " />
<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 " />
<titlu />
<actualizat> 2015-05-19T03: 38: 50Z </updated>
<autor>
<nume />
</author>
<content type = "application / xml" >
<m: proprietăți>
<d: ID m: type = "Int32" > 1 </ d: ID>
<d: Nume> Lapte </ d: Nume>
<d: Descriere> Lapte cu conținut scăzut de grăsimi </ d: Descriere>
<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: Preț m: type = "Double" > 3,5 </ d: Preț>
</ m: proprietăți>
</content>
</entry>
...
</feed>

Un exemplu de document de metadate OData

 <edmx: Edmx Version = "4.0" xmlns: edmx = "http://docs.oasis-open.org/odata/ns/edmx" >
<edmx: DataServices>
<Schema Nume spațiu = "ODataDemo" xmlns = "http://docs.oasis-open.org/odata/ns/edm" >
<EntityType Name = "Produs" >
<Cheie>
<PropertyRef Name = "ID" />
</Key>
< Nume proprietate = "ID" Tip = "Edm.Int32" Nulabil = "fals" />
< Nume proprietate = "Nume" Tip = "Edm.String" />
< Nume proprietate = "Descriere" Tip = "Edm.String" />
< Nume proprietate = "ReleaseDate" Type = "Edm.DateTimeOffset" Nullable = "false" />
< Nume proprietate = "DiscontinuedDate" Type = "Edm.DateTimeOffset" />
< Nume proprietate = "Rating" Type = "Edm.Int16" Nullable = "false" />
< Nume proprietate = "Preț" Tip = "Edm.Double" Nulabil = "fals" />
</EntityType>

<ComplexType Name = "Address" >
< Nume proprietate = "Stradă" Type = "Edm.String" />
< Nume proprietate = "Oraș" Type = "Edm.String" />
< Nume proprietate = "State" Type = "Edm.String" />
< Nume proprietate = "Cod Zip" Tip = "Edm.String" />
< Nume proprietate = "Țară" Tip = "Edm.String" />
</ComplexType>
      
<EntityContainer Name = "DemoService" >
<EntitySet Name = "Products" EntityType = "ODataDemo.Product" > </EntitySet>
</EntityContainer>
</Schema>
</ edmx: DataServices>
</ edmx: Edmx>

Notă

Elemente conexe

linkuri externe

OData OASIS standard