Rest Wcf resful服务方法=";删除“;

Rest Wcf resful服务方法=";删除“;,rest,wcf,Rest,Wcf,我的方法的合同如下: [OperationContract] [WebInvoke( Method = "DELETE", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/myMethod({myParametar})", BodyStyle = WebMessageBodyStyle.Bare )]

我的方法的合同如下:

[OperationContract]
[WebInvoke(
        Method = "DELETE", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/myMethod({myParametar})", BodyStyle = WebMessageBodyStyle.Bare
                )]
    void myMethod(string myParametar);
我这样称呼它:

[OperationContract]
[WebInvoke(
        Method = "DELETE", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/myMethod({myParametar})", BodyStyle = WebMessageBodyStyle.Bare
                )]
    void myMethod(string myParametar);
)

它说这种方法是不允许的。
为什么?

如果您使用web浏览器调用它,它会发出一个
GET
。相反,您可以使用类似的客户端来测试这一点,这样可以将方法设置为
DELETE

另外,我不相信您可以按照声明的方式将参数传递到括号中(我可能错了,但我不记得曾经见过它)。相反,可以将段指定为参数:

UriTemplate=“/{myParameter}”

或者在查询字符串上传递它:

UriTemplate=“?myMethod={myParameter}”