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