簡體   English   中英

WCF Rest服務中不允許使用此方法

[英]Method not allowed in WCF Rest service

 [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.

有任何想法嗎? 另外,當我去瀏覽器上執行此操作時。 它說找不到端點。 (移動)是虛擬目錄,而(POS)是service1.cs的注冊路由

從瀏覽器發布到URL無效。 您需要自定義代碼或使用提琴手(使用Composer並選擇POST) 與解決方案的另一個鏈接。

答案在“每次我在瀏覽器上運行時都說:”下,您的Web瀏覽器請求是GET請求。您可以將WebInvoke更改為WebGet並刪除POST Method屬性或使用工具構建POST請求。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM