以下是我在测试应用程序中使用的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.IO;
namespace MyWCFServices
{
[ServiceContract]
interface IHelloWorldService
{
[OperationContract]
String GetMessage(String name);
//[OperationContract]
//[WebInvoke(Method = "PUT",UriTemplate = "File/{fileName}")]
//[WebContentType("application/octet-stream")]
// bool UploadFile(string fileName, Stream fileContents);
[OperationContract]
[WebInvoke(UriTemplate = "UploadFile/{fileName}")]
void UploadFile(string fileName, Stream fileContent);
}
}
它为webinvoke编译提供了错误。关于相同的任何想法?
最佳答案
WebInvokeAttribute
在单独的程序集System.ServiceModel.Web.dll中。你提到那个大会了吗?另外,您还必须添加using System.ServiceModel.Web;
编辑:
若要使用System.ServiceModel.Web.dll程序集,必须至少使用.NET 3.5,并且不能使用.NET 4.0客户端配置文件。
关于.net - 找不到WCF REST Webinvoke,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5778388/