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.
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