How to send IReturnVoid requests in a batch

Hello,

I’m migrating a code base from V4.0.42 to V4.0.48 and I found that I cannot send/receive a batch of IReturnVoid requests anymore. Batches that returns a value (IReturn< SomeClass >) work as expected.

The request is serialized correctly but the response contains an error. If I put a breakpoint into the service I can see that it is call for every item that are posted so it looks like the error comes from ServiceStack’s way of handling batches. Did something change in the latest release? I did not see anything related to that in the release notes.

I included below the requests & code.

Request:

POST http://..../json/oneway/HelloPost[] HTTP/1.1
Accept: application/json
User-Agent: ServiceStack .NET Client 4.048
Accept-Encoding: gzip,deflate
Content-Type: application/json
Host: ....
Content-Length: 82
Expect: 100-continue
Connection: Keep-Alive

[{"Name":"A","Name2":"123"},{"Name":"B","Name2":"123"},{"Name":"C","Name2":"123"}]
Response: (I'm including only the relevant part from the IIS error page)

[NullReferenceException]: Object reference not set to an instance of an object.
   at System.Object.GetType()
   at ServiceStack.Host.Handlers.ServiceStackHandlerBase.<>c__DisplayClass6.<HandleResponse>b__4(Task task)
   at ServiceStack.AsyncExtensions.Continue[TOut](Task task, Func`2 next)
[AggregateException]: One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at ServiceStack.Host.Handlers.HttpAsyncTaskHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)
// .Net code

    [Route("/helloBatch", Verbs = "POST")]
    [DataContract]
    public class HelloPost : IReturnVoid
    {
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public string Name2 { get; set; }
    }

// Service
        public async Task Any(HelloPost request)
        {
            await Task.FromResult(0); // simulation of our complex process
        }

// unit test 
    var client = new JsonServiceClient("http://.../");
    client.SendAllOneWay(new[]
                        {
                            new HelloPost{Name = "A", Name2 = "123"},
                            new HelloPost{Name = "B", Name2 = "123"},
                            new HelloPost{Name = "C", Name2 = "123"}
                        })

I tried changing the Service to return void instead of a Task however I receive the same error formatted in json instead of the IIS error page:

{"responseStatus":{"errorCode":"NullReferenceException","message":"Object reference not set to an instance of an object.","stackTrace":"   at System.Object.GetType()\r\n   at ServiceStack.Host.ServiceController.<>c__DisplayClass21.<CreateAutoBatchServiceExec>b__1d(IRequest req, Object dtos)\r\n   at ServiceStack.Host.ServiceController.Execute(Object requestDto, IRequest req)\r\n   at ServiceStack.HostContext.ExecuteService(Object request, IRequest httpReq)\r\n   at ServiceStack.Host.Handlers.GenericHandler.GetResponse(IRequest httpReq, Object request)\r\n   at ServiceStack.Host.Handlers.GenericHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)"}}

Should now be resolved with this commit available from v4.0.49 that’s now available on MyGet.