WCF 批量响应格式不正确
我正在使用 WCF 数据服务的处理管道在处理更改集之前进行一些消息通知设置。我正在使用批处理模式来提交我的更改。我正在测试通知服务未运行的场景,因此我们在更改集处理之前抛出特定消息。
以下是我的代码的设置方式
ProcessingPipeline.ProcessingChangeset += ProcessingChangeset;
您可以轻松地模仿我的错误,如下所示:
private void ProcessingChangeset(object sender, EventArgs e)
{
throw new Exception("Some Specific Messsage");
}
当我运行测试时,我没有收到我期望的“某些特定消息”异常。相反,我收到:
System.Data.Services.Client.DataServiceRequestException:错误 处理此请求时发生。 ---> System.InvalidOperationException:缺少更改集边界 分隔符。请确保更改集边界分隔符是 指定标记更改集的结束。
我使用 Fiddler 检查了测试响应以查看内容。
--batchresponse_f158ae30-03c4-479e-8dda-a9129d2a1036
Content-Type: multipart/mixed; boundary=changesetresponse_92c24e82-47ad-43a2-b3e2-79d9e5ada261
--batchresponse_f158ae30-03c4-479e-8dda-a9129d2a1036
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 500 Internal Server Error
DataServiceVersion: 1.0;
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-US">An error occurred while processing this request.</message>
<innererror>
<message>Some Specific Message</message>
<type>System.Exception</type>
<stacktrace> at SM.Service.BaseService`1.ProcessingChangeset(Object sender, EventArgs e) in C:\svn\gr-core\ServiceManager\trunk\SM.Service\BaseService.cs:line 71
at System.Data.Services.DataServiceProcessingPipeline.InvokeProcessingChangeset(Object sender, EventArgs e)
at System.Data.Services.DataService`1.BatchDataService.HandleBatchContent(Stream responseStream)</stacktrace>
</innererror>
</error>
--changesetresponse_92c24e82-47ad-43a2-b3e2-79d9e5ada261
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 204 No Content
Content-ID: 2
Cache-Control: no-cache
DataServiceVersion: 1.0;
--changesetresponse_92c24e82-47ad-43a2-b3e2-79d9e5ada261--
--batchresponse_f158ae30-03c4-479e-8dda-a9129d2a1036--
看来重复的批量响应条目可能是问题所在。有没有人遇到过这种情况或找到解决方法以便可以返回适当的消息?
我们的其他功能测试在更改集处理(而不是之前)中出现错误时都会返回预期的消息。
I am using WCF Data Service's processing pipeline do some message notification set-up prior to processing the change sets. I am using batch mode to submit my changes. I am testing a scenario where the notification service is not running, and therefore we throw a specific message prior to the change set processing.
Here's how my code is set up
ProcessingPipeline.ProcessingChangeset += ProcessingChangeset;
You can easily mimic my error as follows:
private void ProcessingChangeset(object sender, EventArgs e)
{
throw new Exception("Some Specific Messsage");
}
When I run my test, I do not get the "Some Specific Message" exception that I expect. Instead I receive:
System.Data.Services.Client.DataServiceRequestException: An error
occurred while processing this request. --->
System.InvalidOperationException: Missing change set boundary
delimiter. Please make sure that change set boundary delimiter is
specified to mark the end of a change set.
I inspected the test response using Fiddler to see the contents.
--batchresponse_f158ae30-03c4-479e-8dda-a9129d2a1036
Content-Type: multipart/mixed; boundary=changesetresponse_92c24e82-47ad-43a2-b3e2-79d9e5ada261
--batchresponse_f158ae30-03c4-479e-8dda-a9129d2a1036
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 500 Internal Server Error
DataServiceVersion: 1.0;
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-US">An error occurred while processing this request.</message>
<innererror>
<message>Some Specific Message</message>
<type>System.Exception</type>
<stacktrace> at SM.Service.BaseService`1.ProcessingChangeset(Object sender, EventArgs e) in C:\svn\gr-core\ServiceManager\trunk\SM.Service\BaseService.cs:line 71
at System.Data.Services.DataServiceProcessingPipeline.InvokeProcessingChangeset(Object sender, EventArgs e)
at System.Data.Services.DataService`1.BatchDataService.HandleBatchContent(Stream responseStream)</stacktrace>
</innererror>
</error>
--changesetresponse_92c24e82-47ad-43a2-b3e2-79d9e5ada261
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 204 No Content
Content-ID: 2
Cache-Control: no-cache
DataServiceVersion: 1.0;
--changesetresponse_92c24e82-47ad-43a2-b3e2-79d9e5ada261--
--batchresponse_f158ae30-03c4-479e-8dda-a9129d2a1036--
It looks like the duplicate batchresponse entries may be the issue. Has anyone encountered this or found a work around so the appropriate message can be returned?
Our other functional tests that have errors in the change set processing (not prior) all return the expected messages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这确实看起来像一个错误。我检查了我们最近的构建,行为肯定更好(没有重复的边界,但据我所知是正确的错误响应)。
您可以尝试最新的 CTP,它可能已修复此问题:http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and- silverlight-4.aspx
This does indeed look like a bug. I checked on our recent builds and the behavior is definitely better (no duplicate boundaries, but a correct error response as far as I can tell).
You could try the latest CTP which might have this fixed here: http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and-silverlight-4.aspx