2012-08-08 56 views
0

任何帮助,非常感谢。Azure存储表UpdateObject - 其中一个请求输入无效

我正在使用Azure存储表的1.6 SDK。在UpdateObject()我收到以下错误:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <code>InvalidInput</code> 
    <message xml:lang="en-US">One of the request inputs is not valid. 
RequestId:b78bc343-f93c-4ec7-8991-24386131de43 
Time:2012-08-08T01:25:32.4366914Z</message> 
</error> 

这里的请求(从小提琴手拉):

MERGE https://foo.table.core.windows.net/foo('87a23657-9206-4450-a7ca-09d599b41b9f') HTTP/1.1 
User-Agent: Microsoft ADO.NET Data Services 
DataServiceVersion: 1.0;NetFx 
MaxDataServiceVersion: 2.0;NetFx 
x-ms-version: 2011-08-18 
x-ms-date: Wed, 08 Aug 2012 01:24:56 GMT 
Authorization: SharedKeyLite <foo> 
Accept: application/atom+xml,application/xml 
Accept-Charset: UTF-8 
Content-Type: application/atom+xml 
If-Match: * 
Host: foo.table.core.windows.net 
Content-Length: 1047 

<?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 /> 
    <author> 
    <name /> 
    </author> 
    <updated>2012-08-08T01:24:56.9434703Z</updated> 
    <id>https://foo.table.core.windows.net/foo('87a23657-9206-4450-a7ca-09d599b41b9f')</id> 
    <content type="application/xml"> 
    <m:properties> 
     <d:EmailAddress>foo</d:EmailAddress> 
     <d:Enabled m:type="Edm.Boolean">false</d:Enabled> 
     <d:Id>87a23657-9206-4450-a7ca-09d599b41b9f</d:Id> 
     <d:LastSignIn m:null="true" /> 
     <d:Name>new</d:Name> 
     <d:PIN>0000</d:PIN> 
     <d:PartitionKey>sandbox</d:PartitionKey> 
     <d:RowKey>87a23657-9206-4450-a7ca-09d599b41b9f</d:RowKey> 
     <d:SignupDate m:null="true" /> 
     <d:Timestamp m:type="Edm.DateTime">0001-01-01T00:00:00</d:Timestamp> 
    </m:properties> 
    </content> 
</entry> 

这里的调用UpdateObject():

Public Sub Update(existingItem As UserDataModel) 
    _ServiceContext.AttachTo(UserDataServiceContext.UserTableName, existingItem, "*") 
    _ServiceContext.UpdateObject(existingItem) 
    _ServiceContext.SaveChanges() 
End Sub 

以下是初始化服务上下文的代码:

Public Sub New() 
    Try 
     Dim storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString") 
     _ServiceContext = New UserDataServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials) 
     _ServiceContext.IgnoreResourceNotFoundException = True 
     ' Create the tables 
     ' In this case, just a single table. 
     storageAccount.CreateCloudTableClient().CreateTableIfNotExist(UserDataServiceContext.UserTableName) 
    Catch ex As Exception 
     Debug.WriteLine("Problem with New() UserDataSource. Error: " & ex.Message) 
    End Try 
End Sub 

让我知道如果有什么我可以提供...

干杯,

托马斯

编辑1: 这里有一个插入成功是什么样子的小提琴手:

POST https://foo.table.core.windows.net/<tablename> HTTP/1.1 
User-Agent: Microsoft ADO.NET Data Services 
DataServiceVersion: 1.0;NetFx 
MaxDataServiceVersion: 2.0;NetFx 
x-ms-version: 2011-08-18 
x-ms-date: Wed, 08 Aug 2012 15:41:36 GMT 
Authorization: SharedKeyLite <key> 
Accept: application/atom+xml,application/xml 
Accept-Charset: UTF-8 
Content-Type: application/atom+xml 
Host: <tablename>.table.core.windows.net 
Content-Length: 990 

<?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 /> 
    <author> 
    <name /> 
    </author> 
    <updated>2012-08-08T15:41:36.3923506Z</updated> 
    <id /> 
    <content type="application/xml"> 
    <m:properties> 
     <d:EmailAddress>[email protected]</d:EmailAddress> 
     <d:Enabled m:type="Edm.Boolean">false</d:Enabled> 
     <d:Id>74cdf74d-4eea-40b8-93c4-a7f8bc01c387</d:Id> 
     <d:LastSignIn>634800372963013454</d:LastSignIn> 
     <d:Name>(test)</d:Name> 
     <d:PIN>0000</d:PIN> 
     <d:PartitionKey>sandbox</d:PartitionKey> 
     <d:RowKey>74cdf74d-4eea-40b8-93c4-a7f8bc01c387</d:RowKey> 
     <d:SignupDate>634800372963013454</d:SignupDate> 
     <d:Timestamp m:type="Edm.DateTime">0001-01-01T00:00:00</d:Timestamp> 
    </m:properties> 
    </content> 
</entry> 
+0

这是针对devstorage运行吗?有时它的行为与文档所述不同。例如,插入或合并操作似乎不适用于此。 – 2012-08-08 19:30:52

+0

上述代码在本地Azure计算模拟器的WCF服务中运行,但它正在访问远程Azure云存储。 – 2012-08-09 00:30:32

回答

1

该URL看起来不对,但我不确定它是如何得到这种方式的......它通常应该是类似于https://<account>.table.core.windows.net/<table>(PartitionKey='<pkey>',RowKey='<rkey>')。但我没有解释你为什么看起来不正确。 (代码看起来相当简单。)

是否可以执行其他操作,如插入?当你这样做的时候,这些网址在Fiddler中看起来是否正确?

+0

嗨史蒂夫 - 我已经添加了一个成功的插入请求跟踪到上面的问题。 – 2012-08-08 15:47:02

+0

谢谢。糟糕,我猜插入的网址没有相同的结构。 – smarx 2012-08-08 17:37:59

相关问题