WCF Methods with Large Result Sets - Tracking Progress Tracking

I have WCF services that need to return some datasets up to 10MB or more, I want visual feedback to the user about the progress, is there a way to track the progress of the download?

My client is Silverlight 3 and I would ultimately like to bind a progress bar to it; any ideas?

EDIT: After the bounty SO automatically picked an answer with upvotes as the correct answer when it isn't.

+2


source to share


4 answers


Here's an example of this in a code project:



http://www.codeproject.com/KB/WCF/WCF_FileTransfer_Progress.aspx

+5


source


If you have one giant WCF call then you only have two states, all or nothing. In addition, WCF has a maximum transaction size, so returning a large dataset carries the risk of overcoming this limit.

To solve these problems in my projects, I split one big query into many small queries. Then I check how many responses I have versus the original requests to get an indication of progress.



Edit: Added better explanation.

+1


source


The CodeProject article can be tricky to work with Silverlight as Silverlight only has access to BasicHttpBinding - although it looks like BasicHttpBinding has TransferMode = "Streaming", maybe maybe - I don't know.

If you can get it to return a stream, it looks like this is the best approach.

However, I thought I would come up with an occasional "different" approach.

Perhaps you could serialize the data to a file and use the WebClient to load it. This way you will have WS.GetData () that will save the file to the server and return its filename - then the Silverlight application will use the WebClient to download it (with the DownloadProgressChanged event).

I know this is not what you are looking for - just an idea ...

0


source


EDIT . I answered thinking that you want to load Silverlight, but it actually looks like you want to load Silverlight. You can do the same as I suggested for the bootloader, except using HTTP GET or binary WCF or Sockets.

I wrote a Silverlight 2 loader with a progress bar and I modeled it after this . It uses HTTP POST to send a file to the server one at a time. The tricky part is that the larger your POST, the faster the file will load, but your progress bar only updates once per POST. So I wrote an algorithm that dynamically tries to find the largest POST size, which takes less than a second.

If you want to use WCF instead of HTTP POST, this is probably better, because Silverlight 3 now supports encoding binary messages:

<customBinding> <binding name = "MyBinaryBinding" maxBufferSize = "2147483647" MaxReceivedMessageSize = "2147483647"> <binaryMessageEncoding /> <httpTransport /> </ binding> </customBinding>

OR you could write a socket implementation - Silverlight does support this, but it can be a little tricky to configure and requires your server to have a port in the range 4502-4532 and port 943 open to the policy file .

0


source







All Articles