- Posted by Ian Suttle on November 29, 2007
- Filed under .NET 3.5 | ASP.Net | AJAX | .Net Framework
Scott Guthrie has announced ASP.NET 3.5 Extensions public preview will be released next week sometime. This is really a big hitter people have been clammoring about... MVC, Entity Framework, Astoria, and more!
After stumbling upon it on a MS labs site I've been following Astoria for a few months now. An Astoria overview describes its purpose better than I can:
"The goal of Astoria is to facilitate the creation of flexible data services that are naturally integrated with the web. As such, Astoria uses URIs to point to pieces of data and simple, well-known formats to represent that data, such as JSON and plain XML. This results in the data service being surfaced to the web as a REST-style resource collection that is addressable with URIs and that agents can interact with using the usual HTTP verbs such as GET, POST or DELETE."
... using a REST-style request to get XML or JSON formatted data in a .NET Framework sanctioned way is just what the doctor ordered. Here's a sample request and output:
Request: http://myserver/data.svc/Customers[ALFKI]
XML:
DataService xml:base="http://myserver/data.svc">
<Customers>
<Customer uri="Customers[ALFKI]">
<CustomerID>ALFKI</CustomerID>
<CompanyName>Alfreds Futterkiste</CompanyName>
<ContactName>Maria Anders</ContactName>
<ContactTitle>Sales Representative</ContactTitle>
<Address>Obere Str. 57</Address>
<City>Berlin</City>
<Region />
<PostalCode>12209</PostalCode>
<Country>Germany</Country>
<Phone>030-0074321</Phone>
<Fax>030-0076545</Fax>
<Orders href="Customers[ALFKI]/Orders" />
</Customer>
</Customers>
</DataService>
JSON:
[
{
__metadata: {
Type: "Customer",
Base: "http://myserver/data.svc",
Uri: "Customers[ALFKI]"
},
CustomerID: "ALFKI",
CompanyName: "Alfreds Futterkiste",
ContactName: "Maria Anders",
ContactTitle: "Sales Representative",
Address: "Obere Str. 57",
City: "Berlin",
Region: null,
PostalCode: "12209",
Country: "Germany",
Phone: "030-0074321",
Fax: "030-0076545",
Orders: {
__metadata: {
Uri: "Customers[ALFKI]/Orders"
}
}
}
]