Wcf 方法访问头报错 怎么解决

下面是我在WCF服务中写的代码

 [OperationContract]
         [WebInvoke(
           Method = "POST",
             BodyStyle = WebMessageBodyStyle.WrappedRequest,
             ResponseFormat = WebMessageFormat.Json,
             RequestFormat = WebMessageFormat.Json)]
        void DoWork(string jsonstr,int boxid);

为什么WebInvoke报错?错误提示“未找到类型或命名空间WebInvoke(是否缺少using指令或程序集引用)”。怎么解决?

你的项目需要引用System.ServiceModel.Web.dll

且在文件里面加入using System.ServiceModel.Web;