I am sending and receiving large arrays of objects to and from a WCF service. I am splitting the array into chunks and sending those, so that each call is not too large.
The code looks something like this:
//split data up so there is no "400 - Bad Request" error
int length = 2000;
if (requests.Length > length)
{
CustomerMatching[] array = new CustomerMatching[length];
for (int first = 0; first < requests.Length; first += length)
{
if (first + length >= requests.Length)
{
length = requests.Length - first;
array = new CustomerMatching[length];
}
Array.Copy(requests, first, array, 0, length);
r += client.RequestCustomerMatchings(array);
}
}
else
{
//Should be able to stream the whole dataset in one go
r = client.RequestCustomerMatchings(requests);
}
This works fine, but it is much slower than sending it all in one go, and I suspect that having to copy the entire array to send it doesn't help.
Can I send slices of the array one at a time via WCF without copying each chunk?