[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.
有什么想法吗?当我在浏览器上执行此操作时。它说Endpoint没找到。 (Mobile)是虚拟目录,而(POS)是service1.cs的注册路径
答案 0 :(得分:0)
从浏览器发布到URL无效。您需要自定义代码或使用fiddler(使用Composer并选择POST)Another link with solution.
答案 1 :(得分:0)
答案在下“每当我在浏览器上运行它时说:”
您的Web浏览器请求是GET请求。您可以将WebInvoke
更改为WebGet
并删除POST方法属性或使用工具构建POST请求。