开发者

WCF REST Webinvoke not found

开发者 https://www.devze.com 2023-02-28 07:37 出处:网络
Following is the code i am using in my test app: using System; using System.Collections.Generic; using System.Linq;

Following is the code i am using in my test app:

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]
        St开发者_开发技巧ring 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); 
    }
}

It gives and error on compilation for webinvoke. Any idea about the same ??


WebInvokeAttribute is in separate assembly System.ServiceModel.Web.dll. Did you reference that assembly? Also you must add using System.ServiceModel.Web;

Edit:

To use System.ServiceModel.Web.dll assembly you must use at least .NET 3.5 and you can't use .NET 4.0 Client Profile.

0

精彩评论

暂无评论...
验证码 换一张
取 消