|
|

For request in operation xx to be a stream the operation must have a single parameter whose type is Stream.
翻译:在操作中的请求是一个流的操作必须有一个单一的参数,其类型是流。
我的大体理解意思就是,如果参数为stream流,就不能有其他的参数,
我方法里面有3个参数,可能是这个原因吧,毕竟刚玩wcf,对这套还不熟悉。
http://stackoverflow.com/questions/15495506/for-request-in-operation-uploadphotostream-to-be-a-stream-the-operation-must-hav/15609508
- namespace StackSample.Logic
- {
- [ServiceHeaderBehavior]
- [MerchantHeaderBehavior]
- [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
- public class Merchant : Interfaces.IMerchant
- {
- public bool UploadPhotoStream(string productid, string photoid, Stream fileData)
- {
- Logic.Components.Product ca = new Logic.Components.Product();
- return ca.UploadPhotoStream(Common.UserValues().Merchant, productid, photoid, fileData);
- }
- }
- }
- namespace StackSample.Interfaces
- {
- [ServiceContract]
- public interface IMerchant
- {
- [OperationContract]
- [WebInvoke(UriTemplate = "UploadPhotoStream?productid={productid}&photoid={photoid}", Method = "POST")]
- bool UploadPhotoStream(string productid, string photoid, Stream fileData);
- }
- }
复制代码 看到那哥们,错误和我差不多。
解决办法如下:
定义一个对象,如下:
- [DataContract]
- public class UploadModel
- {
- [DataMember]
- public string Name { get; set; }
- [DataMember]
- public Stream stream { get; set; }
- }
复制代码
- [ServiceContract]
- public interface WcfService
- {
- [OperationContract]
- bool Upload(UploadModel file,out string Image_Path);
- }
复制代码
|
上一篇:WCF数据通信参数不能是Image类型?下一篇:Type 'System.IO.FileStream' with data contract name 'FileStream:http://schema...
|