是否可以将 Stream 作为 WCF 数据服务操作的参数?
请注意,此问题特定于 WCF 数据服务,而不是普通的 Wcf 服务。
我正在尝试将文件上传到服务,但没有任何运气。
一旦我添加以下代码:
[WebInvoke(Method = "POST")]
public void UploadPic(Guid id, Stream fileContents)
{
myImageSaver.SaveImageFromStream(fileContents);
}
我的整个数据服务崩溃了。我无法查询任何实体集。我刚刚遇到蓝色 WCF 死机屏幕。
Please note this question is specific 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可能将流作为参数传递给服务操作,仅支持原始类型作为服务操作的参数。在 WCF 数据服务中支持流的正确方法是使用 MLE/MR 功能。请查看此博客系列,了解如何实现此类服务的详细演练:
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
是的,这是可能的,请参阅此处的示例: http://forums.asp.net/t /1376821.aspx/1
Yes it is possible, see the example here: http://forums.asp.net/t/1376821.aspx/1