使用WebInvoke POST方法的C#Restful服务
当我使用以下工具时,我的服务运行良好:使用WebInvoke POST方法的C#Restful服务,c#,rest,post,webinvoke,C#,Rest,Post,Webinvoke,当我使用以下工具时,我的服务运行良好: [OperationContract] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/?id={id}")] string jdata(string id); 我的方法实现是 public string json(string id) {
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/?id={id}")]
string jdata(string id);
我的方法实现是
public string json(string id)
{
return "Your typed String is : " id;
}
到目前为止,它运行良好,
但我必须在WebInvoke中使用Method=POST
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/?id={id}")]
string jdata(string id);
当我使用这个和呼叫服务时,我必须面对不允许的方法。
请解决我的这个小问题……您提供的两个示例是相同的。当你收到错误时,你做了什么不同的事情?亲爱的,被贴错了,请考虑方法=“获得”在这个问题的描述的第二行。谢谢请回复,考虑到我的服务使用Method-GET运行良好,当我更改Method=POST时,我将面临Method Not Allowed的错误。谢谢!如果你不能理解这个页面上的问题,请回复这个链接。谢谢