Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
C# 如何使用POSTMAN或任何客户端工具应用程序调用RestFul WCF POST服务?_C#_Wcf_Web Services_Soapui_Restful Url - Fatal编程技术网

C# 如何使用POSTMAN或任何客户端工具应用程序调用RestFul WCF POST服务?

C# 如何使用POSTMAN或任何客户端工具应用程序调用RestFul WCF POST服务?,c#,wcf,web-services,soapui,restful-url,C#,Wcf,Web Services,Soapui,Restful Url,好吧,假设我想使用POSTMAN或任何其他Rest服务客户机工具来调用我的代码,我应该怎么做?我的一个参数“数据”很大,我不想在URL中包含“数据”或有效负载,我想从正文中调用它 这是实际的代码 [OperationContract(Name = "createNewSurvey")] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wr

好吧,假设我想使用POSTMAN或任何其他Rest服务客户机工具来调用我的代码,我应该怎么做?我的一个参数“数据”很大,我不想在URL中包含“数据”或有效负载,我想从正文中调用它

这是实际的代码

  [OperationContract(Name = "createNewSurvey")]
  [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "post/createNewSurvey")]
  string CreateNewSurvey(string id, string Data);  


 public string CreateNewSurvey(string id, [FromBody]string Data)
  {
      //do somethoinf
      return data;
  }
任何帮助都将不胜感激

谢谢

安装一个名为的工具,然后使用下面的原始请求

URL:http://localhost/Sample/Service1.svc/post/createNewSurvey
User-Agent: Fiddler
Content-Type: application/json
Host: localhost

{"id":"5","Data":"sample data to be sent to server"}
安装名为的工具,然后使用以下原始请求

URL:http://localhost/Sample/Service1.svc/post/createNewSurvey
User-Agent: Fiddler
Content-Type: application/json
Host: localhost

{"id":"5","Data":"sample data to be sent to server"}

在Postman中,您必须在“输入请求URL”框中写入此字符串,并在标题中添加以下两个键:

  • 内容类型:application/json
  • 主机:本地主机
然后在正文中选择“原始”单选按钮并写入:

  • {“id”:“5”,“数据”:“要发送到服务器的样本数据”}

在Postman中,您必须在“输入请求URL”框中写入此字符串,然后选择POST,在标题中添加以下两个键:

  • 内容类型:application/json
  • 主机:本地主机
然后在正文中选择“原始”单选按钮并写入:

  • {“id”:“5”,“数据”:“要发送到服务器的样本数据”}

我认为邮递员更适合OP环境。。。fiddler用于更复杂的检查我认为邮递员更适合OP上下文。。。fiddler用于更复杂的检查