我正在开发一个Windows phone7应用程序。其中一部分是在笔记本电脑上创建一个webrole,用于在Windows Azure云上创建表格,我已经完成了这项工作。我正在Windows phone7上开发一个Silverlight应用程序,它需要访问云来查询表和更新表。我在互联网上的许多地方发现,这可以通过对Windows TAble存储进行RESTful调用来实现。但是我在任何地方都找不到任何示例代码。
谁可以发布一些示例代码RESTful调用Windows Table Storage是如何完成的,这样我就可以从客户端(Silverlight应用程序- Windows phone7)查询和更新表。任何链接和参考也是欢迎的。
发布于 2010-12-13 20:32:55
这是一些关于对Windows Table Storage的RESTful调用的示例代码
列出表格:
http://<storageaccount>.table.core.windows.net/Tables删除表:
http://<storageaccount>.table.core.windows.net/Tables('TableName')为了创建一个新表,您必须创建一个到下一个Uri的POST请求:
POST http://<storageaccount>.table.core.windows.net/Tables这可能是您请求的正文:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<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">
<title />
<updated>2010-11-18T11:48:34.9840639-07:00</updated>
<author>
<name/>
</author>
<id/>
<content type="application/xml">
<m:properties>
<d:TableName>ProductTable</d:TableName>
</m:properties>
</content>
</entry>如果你需要插入一个新实体,你应该使用下一个Uri:
POST http://<storageaccountname>.table.core.windows.net/<TableName>请求正文为以下Atom XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<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">
<title />
<updated>2010-12-13T13:26:48.8875037Z</updated>
<author>
<name />
</author>
<id />
<content type="application/xml">
<m:properties>
<d:Description>My descripcion</d:Description>
<d:Name>Entity Name</d:Name>
<d:PartitionKey>Definitions</d:PartitionKey>
<d:RowKey>Things</d:RowKey>
<d:Timestamp m:type="Edm.DateTime">0001-01-01T00:00:00</d:Timestamp>
</m:properties>
</content>
</entry>删除实体
http://<storageaccountname>.table.core.windows.net/<TableName>(PartitionKey="Definitions",
RowKey="Things")使用REST API更新或合并数据实际上是DELETE和insert REST API的组合。
http://<storageaccountname>.table.core.windows.net/<TableName>(PartitionKey="Definitions",
RowKey="Things")https://stackoverflow.com/questions/4418148
复制相似问题