BreezeJS和IE9的ETAG错误无效

时间:2014-08-15 10:52:39

标签: sharepoint sharepoint-2010 breeze

我正在将BreezeJS与SharePoint适配器一起使用,并在客户端的第二个和后续POST请求中获得一致的无效etag错误。奇怪的是,这不会发生在IE11或最新的谷歌Chrome浏览器中。

以下是有关正在发生的事情的一些细节:

  1. 议程项目(ID 3)从服务器中提取并具有etag值W /" 4"
  2. 议程项目的更新以etag值W /" 4"
  3. 发布到服务器
  4. 同一项目的另一次更新以etag值W /" 4"
  5. 发布到服务器
  6. 我收到错误消息:etag值' 4'在其中一个请求标头中指定的无效。请确保只指定了一个etag值且有效
  7. 错误消息非常有意义,因为我们不能在两个不同的请求中使用相同的ETAG值。使用谷歌浏览器,第二个(和后续的)POST请求具有正确递增的etag值。所以在这种情况下它会发送W /" 5"一切都会好的。

    我注意到第一个POST请求返回新的ETAG(W /" 5")但它没有应用于第二个POST请求。我使用以下版本:

    • BreezeJS:1.4.13
    • 休息适配器:0.2.3
    • SharePoint适配器:0.2.3

    作为参考,我已经包含了来自Fiddler的三个操作的请求和响应。

    获取议程项目

    GET http://intranet/test/_vti_bin/listdata.svc/Agenda?$filter=Id%20eq%203 HTTP/1.1
    DataServiceVersion: 2.0
    Accept: application/json;odata=verbose
    X-Requested-With: XMLHttpRequest
    Referer: http://intranet/test/SitePages/test.aspx#inmeeting/2
    Accept-Language: da
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3)
    Host: intranet
    Connection: Keep-Alive
    
    
    HTTP/1.1 200 OK
    Cache-Control: no-cache
    Content-Type: application/json;charset=utf-8
    Vary: Accept-Encoding
    Server: Microsoft-IIS/7.5
    SPRequestGuid: e4a8e96a-d476-41e8-8445-ecd50fe8f78e
    X-SharePointHealthScore: 0
    DataServiceVersion: 2.0;
    X-AspNet-Version: 2.0.50727
    X-Powered-By: ASP.NET
    MicrosoftSharePointTeamServices: 14.0.0.7015
    X-MS-InvokeApp: 1; RequireReadOnly
    Date: Fri, 15 Aug 2014 10:28:59 GMT
    Content-Length: 1491
    
    {
    "d" : {
    "results": [
    {
    "__metadata": {
    "uri": "http://intranet/test/_vti_bin/listdata.svc/Agenda(3)", "etag": "W/\"4\"", "type": "Microsoft.SharePoint.DataService.AgendaItem"
    }, "ContentTypeID": "0x0100EF440AFE5EDF49AD87D3B9A9484C2C0300ACA340FAC0DE1D49B8514C10085EC342", "Title": "Welcome", "Meeting": {
    "__deferred": {
    "uri": "http://intranet/test/_vti_bin/listdata.svc/Agenda(3)/Meeting"
    }
    }, "MeetingId": 2, "Documents": {
    "__deferred": {
    "uri": "http://intranet/test/_vti_bin/listdata.svc/Agenda(3)/Documents"
    }
    }, "Links": {
    "__deferred": {
    "uri": "http://intranet/test/_vti_bin/listdata.svc/Agenda(3)/Links"
    }
    }, "Responsible": {
    "__deferred": {
    "uri": "http://intranet/test/_vti_bin/listdata.svc/Agenda(3)/Responsible"
    }
    }, "ResponsibleId": 1, "StartTime": "\/Date(1408622400000)\/", "EndTime": "\/Date(1408623120000)\/", "DurationInMinutes": 12, "Done": true, "Comments": null, "Sort": 0, "Id": 3, "ContentType": "Meeting Agenda", "Modified": "\/Date(1408105622000)\/", "Created": "\/Date(1408010077000)\/", "CreatedBy": {
    "__deferred": {
    "uri": "http://intranet/test/_vti_bin/listdata.svc/Agenda(3)/CreatedBy"
    }
    }, "CreatedById": 1, "ModifiedBy": {
    "__deferred": {
    "uri": "http://intranet/test/_vti_bin/listdata.svc/Agenda(3)/ModifiedBy"
    }
    }, "ModifiedById": 1, "Owshiddenversion": 4, "Version": "4.0", "Attachments": {
    "__deferred": {
    "uri": "http://intranet/test/_vti_bin/listdata.svc/Agenda(3)/Attachments"
    }
    }, "Path": "/test/Lists/Agenda"
    }
    ]
    }
    }
    

    议程项目的第一次更新

    POST http://intranet/test/_vti_bin/listdata.svc/Agenda(3) HTTP/1.1
    Accept: application/json;odata=verbose
    Content-Type: application/json;odata=verbose
    DataServiceVersion: 2.0
    X-RequestDigest: 0x5B15EE86ACA321A71DA9A2939E8FE1E2A29D3F6A60A6424C4F497DFFCD4D509836B6FB85A127CBBC947547D8AB7AE0E91CE6C72E7C359D6CF83351C024858D84,15 Aug 2014 10:26:46 -0000
    X-HTTP-Method: MERGE
    If-Match: W/"4"
    X-Requested-With: XMLHttpRequest
    Referer: http://intranet/test/SitePages/test.aspx#inmeeting/2
    Accept-Language: da
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3)
    Host: intranet
    Content-Length: 82
    Connection: Keep-Alive
    Pragma: no-cache
    
    {"Done":false,"__metadata":{"type":"Microsoft.SharePoint.DataService.AgendaItem"}}
    
    HTTP/1.1 204 No Content
    Cache-Control: no-cache
    ETag: W/"5"
    Server: Microsoft-IIS/7.5
    SPRequestGuid: dc4896d6-91b9-4894-a169-c70889ad0747
    X-SharePointHealthScore: 0
    DataServiceVersion: 1.0;
    X-AspNet-Version: 2.0.50727
    X-Powered-By: ASP.NET
    MicrosoftSharePointTeamServices: 14.0.0.7015
    X-MS-InvokeApp: 1; RequireReadOnly
    Date: Fri, 15 Aug 2014 10:29:02 GMT
    

    议程项目的第二次更新

    POST http://intranet/test/_vti_bin/listdata.svc/Agenda(3) HTTP/1.1
    Accept: application/json;odata=verbose
    Content-Type: application/json;odata=verbose
    DataServiceVersion: 2.0
    X-RequestDigest: 0x5B15EE86ACA321A71DA9A2939E8FE1E2A29D3F6A60A6424C4F497DFFCD4D509836B6FB85A127CBBC947547D8AB7AE0E91CE6C72E7C359D6CF83351C024858D84,15 Aug 2014 10:26:46 -0000
    X-HTTP-Method: MERGE
    If-Match: W/"4"
    X-Requested-With: XMLHttpRequest
    Referer: http://intranet/test/SitePages/test.aspx#inmeeting/2
    Accept-Language: da
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3)
    Host: intranet
    Content-Length: 81
    Connection: Keep-Alive
    Pragma: no-cache
    
    {"Done":true,"__metadata":{"type":"Microsoft.SharePoint.DataService.AgendaItem"}}
    HTTP/1.1 412 Precondition Failed
    Cache-Control: private
    Content-Type: application/json
    Server: Microsoft-IIS/7.5
    SPRequestGuid: 965fbf16-8911-426b-9a90-8b21b4a78008
    X-SharePointHealthScore: 0
    DataServiceVersion: 1.0;
    X-AspNet-Version: 2.0.50727
    X-Powered-By: ASP.NET
    MicrosoftSharePointTeamServices: 14.0.0.7015
    X-MS-InvokeApp: 1; RequireReadOnly
    Date: Fri, 15 Aug 2014 10:29:02 GMT
    Content-Length: 214
    
    {
    "error": {
    "code": "", "message": {
    "lang": "en-US", "value": "The etag value '4' specified in one of the request headers is not valid. Please make sure only one etag value is specified and is valid."
    }
    }
    }
    

    更新1

    我已完成一些调试,并从SPAdapter的_processSavedEntity方法开始。在Chrome中,它从响应中接收新的ETAG值,在IE9中它变为null。追溯到此后,我在第15156行的breeze.debug.js(1.4.13)中结束了响应进入系统。在jqXHR上调用getAllResponseHeaders()方法会在IE9中返回一个空字符串,而Fiddler会显示存在的标题(与上面相同)。所以,这有点神秘。 BTW。我使用的是jQuery 1.9.1。

1 个答案:

答案 0 :(得分:2)

问题是IE9和之前的,当收到响应代码204 No Content时,抛弃所有响应头。 这里讨论jQuery.ajax with POST or PUT has no response headers for IE8 and IE9

如果没有并发问题,驱动程序可以嗅探IE9和之前的版本并发出HEAD(我不知道SharePoint是否支持它)或同一实体的GET。 但两种黑客都会产生并发问题。哪一个更糟糕取决于上下文。 在任何情况下,使用ETag进行乐观并发的整个目的都被打败了。 我担心在IE9和之前的版本中,没有办法完全支持OData的乐观并发。