We have built a WCF service, set up as a SOAP service. It reads data from a database, assembles a response and returns it to the client. Because it queries all data it needs from the database, assembles the entire response in memory and returns it to the client, there can be a substantial memory requirement if the amount of data is large.
Basically, the client is requesting a particular record from the database, which contains a blob, which we don't have control over it's size. We expect the size of the data could range from 10k to 3mb or so. Are there techniques we could employ were we could stream the data out of the database and to the WCF response so we don't have to load the full 3mb in memory all at once?
Edit:
Originally, I thought this might be a duplicate of
How to handle large file uploads via WCF?, but that solution requires using Stream as the parameter in the OperationContract. In my case though I need the parameter of my request to be a complex object, which would be reflected in the resulting WSDL of the service.
[ServiceContract]
public interface IFileUpload
{
[OperationContract]
bool UploadFile(Stream stream);
}