在WCF REST服务不允许方法

问题描述:

[OperationContract] 
    [WebInvoke(UriTemplate = "createinvoice", Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] 
    public Invoice CreateInvoice(string instance) 
    { 
     // TODO: Add the new instance of SampleItem to the collection 
     try 
     { 

      string icode = instance; 
      //decimal paid = instance.AmountPaid; 

      return new Invoice() {InvoiceCode = icode }; 
     } 
     catch(Exception) 
     { 
      throw new NotImplementedException(); 
     } 

    } 

每次我在上面说的浏览器中运行呢?另外当我去浏览器上做这个。它说没有找到Endpoint。 (Mobile)是虚拟目录,而(POS)是service1.cs的注册路由在WCF REST服务不允许方法

从浏览器发布到URL将不起作用。你需要你的自定义代码或使用Fiddler(使用Composer和选择POST)Another link with solution.

答案是下“每次我在上面说的浏览器中运行的那样:” Web浏览器的请求是GET请求。你可以将WebInvoke更改为WebGet并删除POST方法属性或使用工具构建POST请求。