Is it possible to have Stream as a parameter to a WCF Data Service Operation?
Please note this question is sp开发者_开发技巧ecific to WCF Data Services not normal Wcf Service.
I'm trying to upload a file to the service without any luck.
As soon as I add the following code:
[WebInvoke(Method = "POST")]
public void UploadPic(Guid id, Stream fileContents)
{
myImageSaver.SaveImageFromStream(fileContents);
}
My whole data service crashes. I cannot query any of the entity sets. I just get the Blue WCF Screen of death.
It's not possible to pass a stream as a prameter to a service operation, only primitive types are supported as parameters to service operations. The proper way of supporting streams in WCF Data Services is to use either the MLE/MR functionality. Take a look at this blog series for a detailed walkthrough of how to implement such service: http://blogs.msdn.com/b/astoriateam/archive/2010/08/04/data-services-streaming-provider-series-implementing-a-streaming-provider-part-1.aspx
Yes it is possible, see the example here: http://forums.asp.net/t/1376821.aspx/1
精彩评论