2

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);
}
Community
  • 1
  • 1
Jeremy
  • 44,950
  • 68
  • 206
  • 332
  • possible duplicate of [How to handle large file uploads via WCF?](http://stackoverflow.com/questions/1935040/how-to-handle-large-file-uploads-via-wcf) – Jeremy Mar 05 '13 at 20:32

2 Answers2

0

Does it have to synchronous?

I presume you've also eye balled this article, if not?

I know WCF is picky with buffer sizes so you will have to pay extra attention to that

Mark Walsh
  • 3,241
  • 1
  • 24
  • 46
0

Streaming Transfer Mode is the best way for Handling bigger Data with WCF. Look at this sample example in msdn to get started WCF Stream Transfer mode

Hope this helps.

Tabish Sarwar
  • 1,505
  • 1
  • 11
  • 18