【问题标题】:Method not allowed in WCF Rest serviceWCF Rest 服务中不允许的方法
【发布时间】:2012-03-11 07:56:20
【问题描述】:
 [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();
        }

    }

每次我在浏览器上运行它都会显示:

Method not allowed. Please see the service help page for constructing valid requests to the service.

有什么想法吗?此外,当我去浏览器上执行此操作时。它说找不到端点。 (Mobile) 是一个虚拟目录,而 (POS) 是 service1.cs 的注册路由

【问题讨论】:

    标签: ajax wcf rest


    【解决方案1】:

    无法从浏览器发布到 URL。您需要自定义代码或使用提琴手(使用 Composer 并选择 POST)Another link with solution.

    【讨论】:

      【解决方案2】:

      答案在 “每次我在浏览器上运行它都会显示:” 您的网络浏览器请求是 GET 请求。您可以将 WebInvoke 更改为 WebGet 并删除 POST Method 属性或使用工具构建 POST 请求。

      【讨论】:

        猜你喜欢
        • 2011-10-01
        • 1970-01-01
        • 2015-11-20
        • 2014-07-17
        • 2012-04-21
        • 2010-09-07
        • 2016-06-13
        • 2011-01-13
        相关资源
        最近更新 更多