views:

885

answers:

5

I have created a WCF service for uploading images , which accepts System.IO.Stream as input parameter and am using streaming. When I added the service reference in Silverlight project then it automatically changed the parameter of my WCF method from System.IO.Stream to byte[]. Can anyone suggest if there is a way around this so that I can get System.IO.Stream type rather than byte[].

Thanks in advance

A: 

I think you should set the transferMode property of your basicHttpBinding to the correct value, as described in this article. And then add the service reference to your Silverlight application again.

Ronald Wildenberg
Thanks for the reply! I already have that property set to "Streamed". When I add this service reference in Windows project it shows IO.Stream but when I add this as service reference in silverlight project it comes out as byte[]
Sai
As Shiraz correctly points out and as I have just learned, Silverlight only supports buffered transfer mode. You could try to implement a solution that uploads an image piece by piece.
Ronald Wildenberg
rwwilden - Silverlight supports Streamed mode as well, what Shiraz meant was System.Io.Streaming is not supported by silverlight when used as parameter in wcf service
Sai
But when I attempt to programmatically configure a BasicHttpBinding inside a Silverlight client, the property TransferMode does not even exist on the BasicHttpBinding. So the only possible way is via sockets, I suppose?
Ronald Wildenberg
On Silverlight client we cannot configure transfer mode it can be configured only on WCF service. there are many limitation in silverlight
Sai
+1  A: 

Silverlight does not support transfer mode streamed: http://forums.silverlight.net/forums/t/119340.aspx

So I think that you are stuck with getting a byte array.

Shiraz Bhaiji
A: 

Now am entirely into a new problem...

I have now modified my WCF service parameters to byte[] instead of stream. Which is well and fine. Now am dividing the image into chunks before I call wcf service. So I send chunks to wcf service and wcf service will inturn collect those chunks and form the image. Now problem is Silverlight is throwing error if chunk size is greater than 16kb. I have given maximum values for maxMessageReceivesize and maxBufferSize but still no luck....

Can anyone suggest if there is a way around this please.

Thanks in advance
Sai

Sai
So, is the concensus that it's not possible to stream a request INTO a WCF operation contract from SL3?I'm having the same problem -- i.e. even though the service is defined as transferMode="Streamed" and I get a Stream parameter generated in a CLR proxy, in a SLR proxy I only get byte[] parameters.
Wayne
+1  A: 

Can you verify that you're not hitting one of the reader quotas in the service? You can try increasing all of them to see if this solves your problem.

carlosf
Readerquota did the trick! Thank you!
Sai
A: 
Manas P Bhuyan