开发者

How do I use streaming with WCF services returning a large data set?

开发者 https://www.devze.com 2023-03-20 22:50 出处:网络
I\'m fairly new to WCF and I\'m trying to figure out how streaming works.I basically have a web service that is supposed to return some information from a db.The data returned is potentially very larg

I'm fairly new to WCF and I'm trying to figure out how streaming works.I basically have a web service that is supposed to return some information from a db.The data returned is potentially very large.I was wondering if anyone could point out a good example of how is this done.If I'm understanding things correctly, my web service method should be returning a stream object.But how do I actually pass data to the stream? Is it just a matter of serializing each object and writing it to the stream? If so, how exactly would the serializait开发者_Python百科ion be done? Once again, a simple example would be very much appreciated.


You should just set the Binding's TransferMode property to the Streamed value and work with your WCF services as you would do. The WCF infrastructure will do all the job automatically.

Here is one more useful link:

Streaming Message Transfer


Actually, I'd revist the architecture, as returning large resultsets from any service (WCF, ASMX, etc) is an architecture smell.

There are very few acceptable reasons to return large resultsets from a service. A combination of more/better filtering and implementing pagine are the solution. If you are just putting a simple service veneer over your database, look into WCF Data Services, as filtering and paging are built right into the framework. Otherwise, look into WCF Data Services to see what they are doing and mimic in your service.

0

精彩评论

暂无评论...
验证码 换一张
取 消