Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用WebInvoke POST方法的C#Restful服务_C#_Rest_Post_Webinvoke - Fatal编程技术网

使用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的错误。谢谢!如果你不能理解这个页面上的问题,请回复这个链接。谢谢